Search in sources :

Example 1 with Retryer

use of feign.Retryer in project pravega by pravega.

the class AuthEnabledMarathonClient method getInstance.

private static Marathon getInstance(String endpoint, RequestInterceptor... interceptors) {
    Feign.Builder b = Feign.builder().client(LoginClient.getClientHostVerificationDisabled()).logger(new Logger.ErrorLogger()).logLevel(Logger.Level.BASIC).encoder(new GsonEncoder(ModelUtils.GSON)).decoder(new GsonDecoder(ModelUtils.GSON)).errorDecoder(new MarathonErrorDecoder()).retryer(new Retryer.Default(SECONDS.toMillis(1), SECONDS.toMillis(5), 5));
    if (interceptors != null) {
        b.requestInterceptors(asList(interceptors));
    }
    b.requestInterceptor(new MarathonHeadersInterceptor());
    return b.target(Marathon.class, endpoint);
}
Also used : GsonEncoder(feign.gson.GsonEncoder) Retryer(feign.Retryer) Feign(feign.Feign) GsonDecoder(feign.gson.GsonDecoder)

Example 2 with Retryer

use of feign.Retryer in project feign by OpenFeign.

the class RealRequestBenchmarks method setup.

@Setup
public void setup() {
    server = HttpServer.newServer(SERVER_PORT).start((request, response) -> null);
    client = new OkHttpClient();
    client.retryOnConnectionFailure();
    okFeign = Feign.builder().client(new feign.okhttp.OkHttpClient(client)).logLevel(Level.NONE).logger(new Logger.ErrorLogger()).retryer(new Retryer.Default()).target(FeignTestInterface.class, "http://localhost:" + SERVER_PORT);
    queryRequest = new Request.Builder().url("http://localhost:" + SERVER_PORT + "/?Action=GetUser&Version=2010-05-08&limit=1").build();
}
Also used : Response(feign.Response) Request(okhttp3.Request) BenchmarkMode(org.openjdk.jmh.annotations.BenchmarkMode) Setup(org.openjdk.jmh.annotations.Setup) Measurement(org.openjdk.jmh.annotations.Measurement) Mode(org.openjdk.jmh.annotations.Mode) Logger(feign.Logger) IOException(java.io.IOException) Scope(org.openjdk.jmh.annotations.Scope) Retryer(feign.Retryer) State(org.openjdk.jmh.annotations.State) Feign(feign.Feign) Level(feign.Logger.Level) Warmup(org.openjdk.jmh.annotations.Warmup) Benchmark(org.openjdk.jmh.annotations.Benchmark) TimeUnit(java.util.concurrent.TimeUnit) OkHttpClient(okhttp3.OkHttpClient) ByteBuf(io.netty.buffer.ByteBuf) OutputTimeUnit(org.openjdk.jmh.annotations.OutputTimeUnit) Fork(org.openjdk.jmh.annotations.Fork) TearDown(org.openjdk.jmh.annotations.TearDown) HttpServer(io.reactivex.netty.protocol.http.server.HttpServer) OkHttpClient(okhttp3.OkHttpClient) Retryer(feign.Retryer) Request(okhttp3.Request) Setup(org.openjdk.jmh.annotations.Setup)

Example 3 with Retryer

use of feign.Retryer in project feign by OpenFeign.

the class ReactiveFeignIntegrationTest method testRetryer.

@Test
public void testRetryer() {
    this.webServer.enqueue(new MockResponse().setBody("Not Available").setResponseCode(-1));
    this.webServer.enqueue(new MockResponse().setBody("1.0"));
    Retryer retryer = new Retryer.Default();
    Retryer spy = spy(retryer);
    when(spy.clone()).thenReturn(spy);
    TestReactorService service = ReactorFeign.builder().retryer(spy).target(TestReactorService.class, this.getServerUrl());
    StepVerifier.create(service.version()).expectNext("1.0").expectComplete().verify();
    verify(spy, times(1)).continueOrPropagate(any(RetryableException.class));
}
Also used : MockResponse(okhttp3.mockwebserver.MockResponse) RetryableException(feign.RetryableException) Retryer(feign.Retryer) Test(org.junit.Test)

Aggregations

Retryer (feign.Retryer)3 Feign (feign.Feign)2 Logger (feign.Logger)1 Level (feign.Logger.Level)1 Response (feign.Response)1 RetryableException (feign.RetryableException)1 GsonDecoder (feign.gson.GsonDecoder)1 GsonEncoder (feign.gson.GsonEncoder)1 ByteBuf (io.netty.buffer.ByteBuf)1 HttpServer (io.reactivex.netty.protocol.http.server.HttpServer)1 IOException (java.io.IOException)1 TimeUnit (java.util.concurrent.TimeUnit)1 OkHttpClient (okhttp3.OkHttpClient)1 Request (okhttp3.Request)1 MockResponse (okhttp3.mockwebserver.MockResponse)1 Test (org.junit.Test)1 Benchmark (org.openjdk.jmh.annotations.Benchmark)1 BenchmarkMode (org.openjdk.jmh.annotations.BenchmarkMode)1 Fork (org.openjdk.jmh.annotations.Fork)1 Measurement (org.openjdk.jmh.annotations.Measurement)1