Skip to content

Polly is a .NET library that provides resilience and transient-fault handling capabilities. This demo implements Polly policies such as Retry and Timeout. It consists of 2 API apps which create requests and responses.

Notifications You must be signed in to change notification settings

ivaaak/CSharp-Polly-Request-Response

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Polly Transient Fault Handling - Request/Response Demo API Project

Polly is a .NET library that provides resilience and transient-fault handling capabilities.

This demo implements Polly policies such as Retry and Timeout. It consists of 2 .NET API apps which create requests and responses.

Request API:

Uses an HTTP Client to call the ResponseAPI and if the request isnt successful it executes the implemented Polly retry/timeout policies.

Examples of the Polly retry/timeout/polling policies used:

ImmediateHttpRetry = Policy
    .HandleResult<HttpResponseMessage>(res => !res.IsSuccessStatusCode)
    .RetryAsync(10);

LinearHttpRetry = Policy
    .HandleResult<HttpResponseMessage>(res => !res.IsSuccessStatusCode)
    .WaitAndRetryAsync(5, retryAttempt => TimeSpan.FromSeconds(3));

ExponentialHttpRetry = Policy
    .HandleResult<HttpResponseMessage>( res => !res.IsSuccessStatusCode)
    .WaitAndRetryAsync(5, retryAttempt => TimeSpan.FromSeconds(Math.Pow(2, retryAttempt)));

Response API:

Calling the API ( /api/response/successPercent ) with a number - successPercent between 0 and 100 (over 100 is always successful) the higher the number is the more likely the response is to be successful.

For example:

  • /api/response/90 --- returns ~ 90% Ok responses
  • /api/response/10 --- returns ~ 10% Ok responses

About

Polly is a .NET library that provides resilience and transient-fault handling capabilities. This demo implements Polly policies such as Retry and Timeout. It consists of 2 API apps which create requests and responses.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages