sony / gobreaker

Circuit Breaker implemented in Go
MIT License
2.89k stars 179 forks source link

Allow custom inspection of errors #29

Closed dmarkhas closed 3 years ago

dmarkhas commented 3 years ago

Not all errors should be counted towards tripping the circuit breaker, this PR adds support for a custom inspection strategy to determine if an error should trip the circuit breaker or not.

xswordsx commented 3 years ago

This would be very useful for my usecase as well - Since gRPC returns errors to denote 4XX Status codes (e.g. NotFound) I am getting a lot of false-positives.

YoshiyukiMineo commented 3 years ago

@dmarkhas

Sorry for the late reply. Your idea sounds good. But I think IsSuccessful is more straightforward than ShouldTrip.

dmarkhas commented 3 years ago

Renamed :)

coveralls commented 3 years ago

Coverage Status

Coverage increased (+0.04%) to 98.99% when pulling 2cbcbadc97db2a9071ecda5ff2a461b7e5902f05 on dmarkhas:inspect_err into 92b9680a31b97b984e5c59865844f538d6f75d45 on sony:master.

coveralls commented 3 years ago

Coverage Status

Coverage decreased (-1.0%) to 97.98% when pulling 425c6ee4796381f8f68fd137b000f8306f84da3b on dmarkhas:inspect_err into 92b9680a31b97b984e5c59865844f538d6f75d45 on sony:master.

dmarkhas commented 3 years ago

Thanks, I've addressed your comments.

YoshiyukiMineo commented 3 years ago

Thank you!

xswordsx commented 3 years ago

Is the next version of the package coming out soon (as I am eagerly awaiting this feature) ?