danielfm / pybreaker

Python implementation of the Circuit Breaker pattern.
BSD 3-Clause "New" or "Revised" License
512 stars 74 forks source link

Allow filter functions to be used for excluded exceptions #39

Closed jshiell closed 5 years ago

jshiell commented 5 years ago

This PR changes the excluded exceptions list to allow a mix of exception types and callable functions, so as to allow for more fine-grained filtering of system exceptions.

This covers cases such as Bottle's HTTPError, where the same exception is used to cover both client errors (HTTP 4xx) and server exceptions (HTTP 5xx). We don't wish to increment the failure counter in cases where we're proxying a request that may cause a client error (e.g. a 404) - hence passing a filter function allows us to differentiate the different uses of this exception type.

danielfm commented 5 years ago

Thanks!

jshiell commented 5 years ago

Thank you!