-
Notifications
You must be signed in to change notification settings - Fork 107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Example of how to integrate into a larger system #495
Comments
Hi @vomc - thanks for the report. Any chance you can provide a reproducible example in code? I suspect it is related somehow to how JavaScript deals with |
Same weird behaviour happened with me. I use an dependency injection resolver and make use of classes. I only can use circuit breaker if I define a anonymous function that calls my class method inside it, otherwise it gives an error inside every foreign classes method calls. For example: const playlistRecommendationService = container.resolve(PlaylistRecommendationService);
const circuitRecommendByCity = new CircuitBreaker(
playlistRecommendationService.recommendByCity,
circuitBreakerOptions,
);
const tracks = await circuitRecommendByCity.fire(cityName); It throws:
But if I use anonymous function, as the example below, everything works. const playlistRecommendationService = container.resolve(
PlaylistRecommendationService,
);
const circuitRecommendByCity = new CircuitBreaker(
() => playlistRecommendationService.recommendByCity(cityName),
circuitBreakerOptions,
);
const tracks = await circuitRecommendByCity.fire(); Also, inside the |
This issue is stale because it has been open 30 days with no activity. |
This issue is stale because it has been open 30 days with no activity. |
@lholmquist do you think we can identify an actual issue to work on here? If not, maybe this issue can be closed? |
This issue is stale because it has been open 30 days with no activity. |
@dayvsonsales It's not connected to the library. This is how JS works. So if you want to call it without anonymous function - you should say to function what it should use as const playlistRecommendationService = container.resolve(PlaylistRecommendationService);
const circuitRecommendByCity = new CircuitBreaker(
playlistRecommendationService.recommendByCity.bind(playlistRecommendationService),
circuitBreakerOptions,
);
const tracks = await circuitRecommendByCity.fire(cityName); |
This issue is stale because it has been open 30 days with no activity. |
Hi,
This is more of a question for an example / documentation links. I am testing out various circuit breakers and opossum is currently on my list. It seems to work well in the toy example provided where you have a simple function but I found that it fails in strange ways if you try to integrated it into a larger system.
For example using
breaker.fire()
on a class method that calls other class methods seems to fail where it eventually complaints that some method is not available... This is strange and I am not sure why it happens and how I would go about integrating this into a larger system.In my case I have a class method that calls another method which I am trying to wrap into the CircuitBreaker, i.e.
breaker.fire(this.api.someOtherMethod)
. ThesomeOtherMethod
calls a method calledpost
in the other class and the error I get now is[Node] ERROR with circuit breaker TypeError: this.post is not a function
Any links to examples would be appreciated!
Thanks
The text was updated successfully, but these errors were encountered: