nodeshift / opossum

Node.js circuit breaker - fails fast ⚡️
https://nodeshift.dev/opossum/
Apache License 2.0
1.3k stars 107 forks source link

How can I get single CB for whole HTTP Client with Opossum? #838

Closed murbanowicz closed 7 months ago

murbanowicz commented 11 months ago

Hi, I really like this project and I appreciate your work on it.

I am missing one thing - how to use single breaker for a e.g. whole HTTP Client for given dependency. Having separate on each method does make much sense in such scenario and having single CB for the single dependency like this makes much more sense.

Is there any way to get it working like that with Opossum?

lholmquist commented 11 months ago

do you have a small code(even pseduo code would work) example of what you are looking for?

murbanowicz commented 11 months ago

E.g.


export class MyHttpClient {
  getOrders() {
     this.circuitBreaker....(???) // call get /orders on target service
  }

    getPayments() {
     this.circuitBreaker....(???) // call get /payments on target service
  }
}

both should use same CB as they are targeting the very same service.
lholmquist commented 11 months ago

If you are using a class, could you just setup the circuit breaker in the constructor and then this.circuitBreaker should reference that single instance?

github-actions[bot] commented 10 months ago

This issue is stale because it has been open 30 days with no activity.

lholmquist commented 7 months ago

closing since we didn't get a response from the previous suggestion