How to configure Hystrixjs in a node app?

Viewed 5168

I am trying to configure hystrixJS into one of my nodejs app. I want to wrap up couple of external dependencies which my app is making. https://www.npmjs.com/package/hystrixjs

I read the readme but I still couldn't get how can i wrap my dependency call with this hystrix and how to configure a dashboard for this. If anyone already tried this before please give me some directions.

Thanks.

3 Answers

An abstraction that might help:

import {commandFactory} from "hystrixjs";

export const CommandsBuilder = class CommandsBuilder {

    static createMyCommand({runFn, fallbackFn}){
        return commandFactory.getOrCreate("my-command-name")
            .run(runFn)
            .fallbackTo(fallbackFn)
            .build();
    }

};
  • runFn: The function that calls the external service
  • fallbackFn: The function called if the service is down or slow

More configuration options under Creating a command in Hystrixjs readme

I also did a post on this.

Related