@Test public void testHystrixCache() throws IOException { MockWebServer server = new MockWebServer(); String content = "Hello world"; MockResponse response = new MockResponse() .setResponseCode(200) .setHeader("Content-type", "text/plain") .setBody(content); server.enqueue(response); server.enqueue(response); server.play(); HttpResourceGroup group = Ribbon.createHttpResourceGroupBuilder("myclient").build(); HttpRequestTemplate<ByteBuf> template = group.newTemplateBuilder("test", ByteBuf.class) .withUriTemplate("http: .withMethod("GET") .withRequestCacheKey("xyz") .build(); RibbonRequest<ByteBuf> request = template .requestBuilder().build(); HystrixRequestContext context = HystrixRequestContext.initializeContext(); try { RibbonResponse<ByteBuf> ribbonResponse = request.withMetadata().execute(); assertFalse(ribbonResponse.getHystrixInfo().isResponseFromCache()); ribbonResponse = request.withMetadata().execute(); assertTrue(ribbonResponse.getHystrixInfo().isResponseFromCache()); } finally { context.shutdown(); } }
public static Builder createHttpResourceGroupBuilder(String name) { return factory.createHttpResourceGroupBuilder(name); }
Ribbon { public static Builder createHttpResourceGroupBuilder(String name) { return factory.createHttpResourceGroupBuilder(name); } }
Ribbon { public static Builder createHttpResourceGroupBuilder(String name) { return factory.createHttpResourceGroupBuilder(name); } private  Ribbon(); }
Ribbon { public static Builder createHttpResourceGroupBuilder(String name) { return factory.createHttpResourceGroupBuilder(name); } private  Ribbon(); static Builder createHttpResourceGroupBuilder(String name); static HttpResourceGroup createHttpResourceGroup(String name); static HttpResourceGroup createHttpResourceGroup(String name, ClientOptions options); static T from(Class<T> contract); }
Ribbon { public static Builder createHttpResourceGroupBuilder(String name) { return factory.createHttpResourceGroupBuilder(name); } private  Ribbon(); static Builder createHttpResourceGroupBuilder(String name); static HttpResourceGroup createHttpResourceGroup(String name); static HttpResourceGroup createHttpResourceGroup(String name, ClientOptions options); static T from(Class<T> contract);  }