Skip to content
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

Add CircuitBreakerMultiplexer #32

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Add CircuitBreakerMultiplexer #32

wants to merge 2 commits into from

Conversation

Timvde
Copy link

@Timvde Timvde commented Dec 28, 2017

It might happen that a particular subsystem only partially fails. For
example, a specific call to an external service might be broken, while
other calls still work. In that case, it might be undesirable to disable
the entire subsystem. This multiplexer allows to dynamically create a
CircuitBreaker based on a method argument.

We needed this in our company, so grab it if you like it :)

@Timvde
Copy link
Author

Timvde commented Dec 28, 2017

Hmm, it does not seem to be Python 2 compatible. We are only using 3.6, so I didn't test this. The failures in Python < 3.4 seem to be unrelated.

If you are willing to take this upstream, I'll invest time into making it work on Python 2.7.

@Timvde
Copy link
Author

Timvde commented Dec 28, 2017

I just discovered an edge case (fix pushed). I'm going further down the Python 3 only route here, though, since my fix is also using introspection functionality that Python 2 just doesn't offer.

As a compromise, I think it would be easiest to leave out support for positional arguments in Python 2 code and only support Python 3. In Python 2, the caller would then be forced to use a keyword argument when calling the function.

I do hope I'm not missing any other edge cases. If you see any, I'm all ears!

@Timvde
Copy link
Author

Timvde commented Dec 28, 2017

Found a minor mistake in one of my test cases too. No changes to the code itself. I just amended the fix to the first commit.

It might happen that a particular subsystem only partially fails. For
example, a specific call to an external service might be broken, while
other calls still work. In that case, it might be undesirable to disable
the entire subsystem. This multiplexer allows to dynamically create a
`CircuitBreaker` based on a method argument.
Given the function definition:

```
@breaker(break_on='b')
def foo(a, *args, b='bar'): ...
```

and caller `foo(1, 2, 3)`, the circuit breaker would mistakenly think
that 3 was binded to b, but it is a keyword only argument.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant