Git Product home page Git Product logo

callquality's Introduction

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(Method1, p1,p2); 
var r4=breaker.Call(Method2, p1,p2,p3);

var r5= new Retry(timeout, maxRetries: 3).Do(Method3, 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)

callquality's People

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.