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

Adsk contrib/add circuit breaker policy interface #205

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Polly.Shared/CircuitBreaker/CircuitBreakerPolicy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Polly.CircuitBreaker
/// <summary>
/// A circuit-breaker policy that can be applied to delegates.
/// </summary>
public partial class CircuitBreakerPolicy : Policy
public partial class CircuitBreakerPolicy : Policy, ICircuitBreakerPolicy
{
private readonly ICircuitController<EmptyStruct> _breakerController;

Expand Down Expand Up @@ -57,7 +57,7 @@ public void Reset()
/// <summary>
/// A circuit-breaker policy that can be applied to delegates returning a value of type <typeparam name="TResult"/>.
/// </summary>
public partial class CircuitBreakerPolicy<TResult> : Policy<TResult>
public partial class CircuitBreakerPolicy<TResult> : Policy<TResult>, ICircuitBreakerPolicy
{
private readonly ICircuitController<TResult> _breakerController;

Expand Down
30 changes: 30 additions & 0 deletions src/Polly.Shared/CircuitBreaker/ICircuitBreakerPolicy.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using System;

namespace Polly.CircuitBreaker
{
/// <summary>
/// Common interface for CB policies allowing users of the library to
/// </summary>
public interface ICircuitBreakerPolicy
{
/// <summary>
/// Gets the state of the underlying circuit.
/// </summary>
CircuitState CircuitState { get; }

/// <summary>
/// Gets the last exception handled by the circuit-breaker.
/// </summary>
Exception LastException { get; }

/// <summary>
/// Isolates (opens) the circuit manually, and holds it in this state until a call to <see cref="Reset()"/> is made.
/// </summary>
void Isolate();

/// <summary>
/// Closes the circuit, and resets any statistics controlling automated circuit-breaking.
/// </summary>
void Reset();
}
}
1 change: 1 addition & 0 deletions src/Polly.Shared/Polly.Shared.projitems
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
<Compile Include="$(MSBuildThisFileDirectory)CircuitBreaker\CircuitState.cs" />
<Compile Include="$(MSBuildThisFileDirectory)CircuitBreaker\CircuitStateController.cs" />
<Compile Include="$(MSBuildThisFileDirectory)CircuitBreaker\HealthCount.cs" />
<Compile Include="$(MSBuildThisFileDirectory)CircuitBreaker\ICircuitBreakerPolicy.cs" />
<Compile Include="$(MSBuildThisFileDirectory)CircuitBreaker\ICircuitController.cs" />
<Compile Include="$(MSBuildThisFileDirectory)CircuitBreaker\IHealthMetrics.cs" />
<Compile Include="$(MSBuildThisFileDirectory)CircuitBreaker\IsolatedCircuitException.cs" />
Expand Down