Giter VIP home page Giter VIP logo

restsharppolly's Introduction

RestSharpPolly

RestSharp with Polly Wrapping the RestClient with Polly framework. Usage:

 var client = RestClientFactory<IRestResponse>.Create(TimeoutAndRetryPolicy.Build(3, 10, 60));
            client.BaseUrl = new Uri("");
            var request = new RestRequest(Method.GET);
            request.AddJsonBody(model);
            var response = client.Execute(request);

The class RestClientFactory is generic.

RestClientFactory<TResult> Create(ISyncPolicy<TResult> syncPolicy)

Install

Import RestSharpPolly into an existing project

Go to the project folder of the application and install the Nuget package reference

$ dotnet add package RestSharpPolly

ID your project using the RestSharp v107, to checkout the branch V107

in the v107 case,

            var client1 = new RestClientFactory<RestResponse>().Create(asyncPolicy2);
            var request1 = new RestRequest();
            
            client1.RestClientOptions.BaseUrl = new Uri("https://httpstat.us/500");
            var host = client1.Build(client1.RestClientOptions);
            var response5 = await host.ExecuteAsync(request1);
            Console.ReadKey();

About v107 branch

NOT fully tested, Not recommended for production use unless you know what you're doing. :) btw official RestSharp 107.3.0 is not compatible with .net45 /.net46 /.net47, so RestSharpPolly does not support for the frameworks.

Upgrading

Simply git pull or git rebase the latest changes

restsharppolly's People

Contributors

m1dst avatar yuessir avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

restsharppolly's Issues

Not getting any output in console App run or Unit Tests.

Thanks so much for contributing this. I think it is exactly what I need. I am trying to confirm everything is working. I believe I should be getting console output messages that confirm that the operation has been re-attempted? When I run the console app there is no output. the system does progress and exit after consuming the three Console.ReadKey() calls however.

right now I am testing this as built. but I hope to get it running with .Net Framework 4.5.2. any advice?

v107 code getting restClient.RestClientOptions throws Exception 'System.NullReferenceException'

`

    var policy = BuildTimeoutAndRetryPolicy2(3, 1, 60);
    IRestClient<RestResponse> restClient = new RestClientFactory<RestResponse>().Create(policy);
    Uri uri = new Uri("http://localhost:5000");
    Console.WriteLine("Host:"+uri.Host);
    restClient.RestClientOptions.BaseUrl = new Uri("http://localhost:5000");
    return restClient.Build(restClient.RestClientOptions);

`

I have tried above code, but getting "Exception thrown: 'System.NullReferenceException' in dotnet-helloworld.dll" on "restClient.RestClientOptions.BaseUrl = new Uri("http://localhost:5000");"

Any idea why RestClientOptions is coming as null
image

Following package version being used

DotNet: 5.0
restsharp: 107.3.0
Polly: 7.2.2

IRestSharp Interface implementation errors

Getting the following build error on this....

Message	"Method 'Execute' on type 'RestSharpPolly.RestClientFactory`1' from assembly 'RestSharpPolly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' tried to implicitly implement an interface method with weaker type parameter constraints."	string

Any ideas?

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.