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 circuit breaker exponential backoff support #4350
Add circuit breaker exponential backoff support #4350
Conversation
@Aaronontheweb I forgot to mention: this introduces a breaking change which will force plugins and such to recompile, since the CircuitBreaker's constructor signature has changed, requiring now a scheduler. |
b797263
to
96fee69
Compare
I'll review the failing tests |
bfa8ebb
to
c530c05
Compare
c530c05
to
f06929e
Compare
1f1323e
to
e9f26fd
Compare
e9f26fd
to
8db2fd4
Compare
8db2fd4
to
cea2806
Compare
cea2806
to
dceea5d
Compare
dceea5d
to
8476846
Compare
@ismaelhamed this needs a rebase - but I'll take a look at it for the 1.4.11 release. I promise <3 |
That's gonna take me a minute, there are some conflicts |
Yep, sorry about that - my fault for not moving on it sooner |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Has some breaking changes but I think this are relatively minor, since the CircuitBreaker
is mostly an internal implementation detail for Akka.Persistence journals
@@ -3884,22 +3884,27 @@ namespace Akka.Pattern | |||
} | |||
public class CircuitBreaker | |||
{ | |||
public CircuitBreaker(int maxFailures, System.TimeSpan callTimeout, System.TimeSpan resetTimeout) { } | |||
public CircuitBreaker(Akka.Actor.IScheduler scheduler, int maxFailures, System.TimeSpan callTimeout, System.TimeSpan resetTimeout) { } | |||
public CircuitBreaker(Akka.Actor.IScheduler scheduler, int maxFailures, System.TimeSpan callTimeout, System.TimeSpan resetTimeout, System.TimeSpan maxResetTimeout, double exponentialBackoffFactor) { } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bit of a breaking change here, but I suppose this really can't be done without passing in the IScheduler
under the circumstances - right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The ResetTimeout is done via the scheduler.
@@ -3915,9 +3920,12 @@ namespace Akka.Pattern | |||
} | |||
public class OpenCircuitException : Akka.Actor.AkkaException | |||
{ | |||
public OpenCircuitException() { } | |||
public OpenCircuitException(System.TimeSpan remainingDuration) { } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This TimeSpan
has a functional purpose, I take it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is only used during the tests, to do some assertions. See #L315
@@ -303,6 +303,29 @@ public void Should_Transition_To_Half_Open_When_Reset_Timeout( ) | |||
Assert.True( InterceptExceptionType<TestException>( ( ) => breaker.Instance.WithCircuitBreaker( () => Task.Factory.StartNew( ThrowException ) ).Wait( ) ) ); | |||
Assert.True( CheckLatch( breaker.HalfOpenLatch ) ); | |||
} | |||
|
|||
[Fact(DisplayName = "An asynchronous circuit breaker that is open should increase the reset timeout after it transits to open again")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
8476846
to
74d8c42
Compare
74d8c42
to
3b7ad6d
Compare
Issue: #21036
This feature has existed in the JVM since 2016, and allows to specify an exponential backoff for the reset timeout.