Skip to content

Commit

Permalink
Add CircuitBreaker Initial based on akka 2.0.5
Browse files Browse the repository at this point in the history
- Add passing tests from akka 2.0.5
- Add CircuitBreakerState.cs with Open, HalfOpen, and Closed states
- Add AtomicState which extends AtomicLong (mirrors functionality of State trait)
- Add OpenCircuitException
- Add CircuitBreaker documentation
- Remove Scheduler from current implementation
- Remove inappropriate xmldoc on illegalstateexception
- Update flow on AtomicState::CallThrough method to be clearer and more closely match original
- Add clarifying comments on "Fire and forget" NotifyTransitionListeners
  • Loading branch information
MAOliver committed Aug 9, 2015
1 parent fce7c0c commit 7e16834
Show file tree
Hide file tree
Showing 11 changed files with 1,118 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/Akka.sln
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.22823.1
# Visual Studio 2013
VisualStudioVersion = 12.0.31101.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Examples", "Examples", "{69279534-1DBA-4115-BF8B-03F77FC8125E}"
EndProject
Expand Down Expand Up @@ -211,6 +213,10 @@ EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Akka.MultiNodeTests", "core\Akka.MultiNodeTests\Akka.MultiNodeTests.csproj", "{F0781BEA-5BA0-4AF0-BB15-E3F209B681F5}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PersistenceBenchmark", "benchmark\PersistenceBenchmark\PersistenceBenchmark.csproj", "{39E6F51F-FA1E-4C62-B8F8-19065DE6D55D}"
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{A59BAE84-70E2-46A0-9E26-7413C103E2D7}"
ProjectSection(SolutionItems) = preProject
WebEssentials-Settings.json = WebEssentials-Settings.json
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
1 change: 1 addition & 0 deletions src/core/Akka.TestKit/Akka.TestKit.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@
<Compile Include="TestActors\BlackHoleActor.cs" />
<Compile Include="TestActors\EchoActor.cs" />
<Compile Include="TestBarrier.cs" />
<Compile Include="TestBreaker.cs" />
<Compile Include="TestFSMRef.cs" />
<Compile Include="ITestKitAssertions.cs" />
<Compile Include="MessageEnvelope.cs" />
Expand Down
30 changes: 30 additions & 0 deletions src/core/Akka.TestKit/TestBreaker.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using System;
using System.Linq;
using System.Runtime.Serialization;
using System.Threading;
using System.Threading.Tasks;
using Akka.Pattern;

namespace Akka.TestKit
{
public class TestBreaker
{
public CountdownEvent HalfOpenLatch { get; private set; }
public CountdownEvent OpenLatch { get; private set; }
public CountdownEvent ClosedLatch { get; private set; }
public CircuitBreaker Instance { get; private set; }

public TestBreaker( CircuitBreaker instance )
{
HalfOpenLatch = new CountdownEvent( 1 );
OpenLatch = new CountdownEvent( 1 );
ClosedLatch = new CountdownEvent( 1 );
Instance = instance;
Instance.OnClose( ( ) => { if ( !ClosedLatch.IsSet ) ClosedLatch.Signal( ); } )
.OnHalfOpen( ( ) => { if ( !HalfOpenLatch.IsSet ) HalfOpenLatch.Signal( ); } )
.OnOpen( ( ) => { if ( !OpenLatch.IsSet ) OpenLatch.Signal( ); } );
}


}
}
1 change: 1 addition & 0 deletions src/core/Akka.Tests/Akka.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@
<Compile Include="MatchHandler\MatchHandlerBuilderTests.cs" />
<Compile Include="MatchHandler\PartialActionBuilderTests.cs" />
<Compile Include="Pattern\BackoffSupervisorSpec.cs" />
<Compile Include="Pattern\CircuitBreakerSpec.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Routing\BroadcastSpec.cs" />
<Compile Include="Routing\ConsistentHashingRouterSpec.cs" />
Expand Down
Loading

0 comments on commit 7e16834

Please sign in to comment.