You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Prior to Polly v5.0, the team was reluctant to introduce interfaces as the execute method overloads were known to be in rapid evolution. These have now stabilized.
Additionally, clear guidance can be given that custom policies should be implemented by extending the Policy base class (intend to wiki/blog example) and not by fulfilling interfaces. This mitigates one usual risk of introducing interfaces in an OSS project: that later evolving the interfaces risks user breakages.
Orthogonal to the execution interfaces would be interfaces specific to each kind of Policy. These would define properties and methods common to that type of policy, whether the policy instance targeted sync or async executions.
with ICircuitBreakerPolicy<TResult> : ICircuitBreakerPolicy adding:
TResult LastHandledResult.
The benefit is that collections of these types of policies can then be managed - say, for monitoring purposes - as outlined by @christopherbahr in #205 .
BulkHead is the only other Polly policy which exposes state, so IBulkheadPolicy is the only other similar interface with content. However, other policy types would have similar empty marker interfaces (eg IRetryPolicy) for parity/completeness.
Registry support
The use of interfaces also supports the forthcoming PolicyRegistry feature, with a proposed empty IsPolicy marker interface identifying policies of all types.
The text was updated successfully, but these errors were encountered:
TL;DR Propose adding interfaces to Polly, in two segregated dimensions.
Interface prototypes already visible in this branch: https://github.com/reisenberger/Polly/commits/feature/interfacesplusregistry
Background
Prior to Polly v5.0, the team was reluctant to introduce interfaces as the execute method overloads were known to be in rapid evolution. These have now stabilized.
Additionally, clear guidance can be given that custom policies should be implemented by extending the Policy base class (intend to wiki/blog example) and not by fulfilling interfaces. This mitigates one usual risk of introducing interfaces in an OSS project: that later evolving the interfaces risks user breakages.
Execution interfaces
Execution interfaces
ISyncPolicy
,IAsyncPolicy
,ISyncPolicy<TResult>
andIAsyncPolicy<TResult>
would define the execution overloads available to policies targeting sync/async, and non-generic / generic calls respectively.Recent blog posts outline why Polly has both non-generic and generic policies and separate sync and async policies.
Policy-kind interfaces
Orthogonal to the execution interfaces would be interfaces specific to each kind of Policy. These would define properties and methods common to that type of policy, whether the policy instance targeted sync or async executions.
For example,
ICircuitBreakerPolicy
definesCircuitState CircuitState
Exception LastException
void Isolate()
void Reset()
with
ICircuitBreakerPolicy<TResult> : ICircuitBreakerPolicy
adding:TResult LastHandledResult
.The benefit is that collections of these types of policies can then be managed - say, for monitoring purposes - as outlined by @christopherbahr in #205 .
BulkHead
is the only other Polly policy which exposes state, soIBulkheadPolicy
is the only other similar interface with content. However, other policy types would have similar empty marker interfaces (egIRetryPolicy
) for parity/completeness.Registry support
The use of interfaces also supports the forthcoming
PolicyRegistry
feature, with a proposed emptyIsPolicy
marker interface identifying policies of all types.The text was updated successfully, but these errors were encountered: