NFRInvoke 2.0.0-prerelease-pending-system-runtime-caching

NFRInvoke - a simple extensible pattern for wrapping function calls for NFRs :retry, circuit-breaker, caching, timing, logging, etc.

Package Description

This is a prerelease version of NFRInvoke.
Install-Package NFRInvoke -Version 2.0.0-prerelease-pending-system-runtime-caching
dotnet add package NFRInvoke --version 2.0.0-prerelease-pending-system-runtime-caching
<PackageReference Include="NFRInvoke" Version="2.0.0-prerelease-pending-system-runtime-caching" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add NFRInvoke --version 2.0.0-prerelease-pending-system-runtime-caching
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

NFRInvoke : a simple pattern for function-call NFRs : retry, circuit-breaker, caching, timing, logging

NFRInvoke provides a simple pattern for addressing software quality requirements, or NFRS, or cross-cutting concerns, around distributed calls. Use it in where you can't or won't use MSIL rewrite techniques.

Currently includes these InvokeWrappers:

  • CircuitBreaker
  • CallTimer
  • Cacher
  • Retry

Examples

var cacher = new Cacher(TimeSpan.FromSeconds(99));
var r1=cacher.Call(ExpensiveMethod);
var r2=cacher.Call(ExpensiveMethod);

var breaker= new CircuitBreaker(""Test1"",1,TimeSpan.FromSeconds(1));
var r3=breaker.Call(FlakyMethod1, p1,p2); 
var r4=breaker.Call(FlakyMethod2, p1,p2,p3);

var r5= new Retry(timeout, maxRetries: 3).Do(FlakyMethod3, 1)
var backoffRetry= new Retry(timeout, Retry.ExponentialBackOff(TimeSpan.FromMilliseconds(10)));
backoffRetry.Call(ContestedMethod);

var callTimes= new List<TimeSpan>();
var callTimer = new CallTimer(ts=> callTimes.Add(ts));
callTimer.Call(SleepAndReturn, 100);
callTimer.Call(SleepAndReturn,1000);
callTimes.First().ShouldBeLessThan( callTimes.Skip(1).First() );

Most InvokeWrapper constructors take optional callback parameters to assist in logging, e.g.:

CircuitBreaker(string circuitName, int? errorsBeforeBreaking = null, TimeSpan? breakForHowLong = null, 
        Type[] exceptionsToThrowNotBreak = null, 
        Type[] exceptionsToBreak = null, 
        Action<string> onBeforeInvoke=null, 
        Action<Exception> onExceptionWasCaught = null, 
        Action<Exception> onExceptionWillBeThrown = null,
        Action<string> onDroppedCallWhileCircuitBroken = null)

Release 2.0.0.0 netstandard20 Relies on package System.Runtime.Caching which is still in pre-release.

NFRInvoke : a simple pattern for function-call NFRs : retry, circuit-breaker, caching, timing, logging

NFRInvoke provides a simple pattern for addressing software quality requirements, or NFRS, or cross-cutting concerns, around distributed calls. Use it in where you can't or won't use MSIL rewrite techniques.

Currently includes these InvokeWrappers:

  • CircuitBreaker
  • CallTimer
  • Cacher
  • Retry

Examples

var cacher = new Cacher(TimeSpan.FromSeconds(99));
var r1=cacher.Call(ExpensiveMethod);
var r2=cacher.Call(ExpensiveMethod);

var breaker= new CircuitBreaker(""Test1"",1,TimeSpan.FromSeconds(1));
var r3=breaker.Call(FlakyMethod1, p1,p2); 
var r4=breaker.Call(FlakyMethod2, p1,p2,p3);

var r5= new Retry(timeout, maxRetries: 3).Do(FlakyMethod3, 1)
var backoffRetry= new Retry(timeout, Retry.ExponentialBackOff(TimeSpan.FromMilliseconds(10)));
backoffRetry.Call(ContestedMethod);

var callTimes= new List<TimeSpan>();
var callTimer = new CallTimer(ts=> callTimes.Add(ts));
callTimer.Call(SleepAndReturn, 100);
callTimer.Call(SleepAndReturn,1000);
callTimes.First().ShouldBeLessThan( callTimes.Skip(1).First() );

Most InvokeWrapper constructors take optional callback parameters to assist in logging, e.g.:

CircuitBreaker(string circuitName, int? errorsBeforeBreaking = null, TimeSpan? breakForHowLong = null, 
        Type[] exceptionsToThrowNotBreak = null, 
        Type[] exceptionsToBreak = null, 
        Action<string> onBeforeInvoke=null, 
        Action<Exception> onExceptionWasCaught = null, 
        Action<Exception> onExceptionWillBeThrown = null,
        Action<string> onDroppedCallWhileCircuitBroken = null)

Release 2.0.0.0 netstandard20 Relies on package System.Runtime.Caching which is still in pre-release.

Version History

Version Downloads Last updated
2.0.0-prerelease-pending-sy... 173 3/5/2018