ratpack.exec.Execution Java Examples
The following examples show how to use
ratpack.exec.Execution.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TimeLimiterMethodInterceptor.java From resilience4j with Apache License 2.0 | 7 votes |
@SuppressWarnings("unchecked") public Object invokeForCompletionStage(MethodInvocation invocation, RecoveryFunction<?> fallbackMethod, io.github.resilience4j.timelimiter.TimeLimiter timeLimiter) { ScheduledExecutorService scheduler = Execution.current().getController().getExecutor(); CompletableFuture<?> future = timeLimiter.executeCompletionStage(scheduler, () -> { try { return (CompletionStage) proceed(invocation); } catch (Throwable t) { final CompletableFuture<?> promise = new CompletableFuture<>(); promise.completeExceptionally(t); return (CompletionStage) promise; } }).toCompletableFuture(); completeFailedFuture(new TimeoutException(), fallbackMethod, future); return future; }
Example #2
Source File: RatpackITest.java From java-specialagent with Apache License 2.0 | 4 votes |
public static void main(final String[] args) throws Exception { final RatpackServer server = RatpackServer.start(new Action<RatpackServerSpec>() { @Override public void execute(final RatpackServerSpec ratpackServerSpec) { ratpackServerSpec.handlers(new Action<Chain>() { @Override public void execute(final Chain chain) { chain.get(new Handler() { @Override public void handle(final Context context) { TestUtil.checkActiveSpan(); context.render("Test"); } }); } }); } }); final HttpClient client = HttpClient.of(new Action<HttpClientSpec>() { @Override public void execute(final HttpClientSpec httpClientSpec) { httpClientSpec .poolSize(10) .maxContentLength(ServerConfig.DEFAULT_MAX_CONTENT_LENGTH) .readTimeout(Duration.of(60, ChronoUnit.SECONDS)) .byteBufAllocator(PooledByteBufAllocator.DEFAULT); } }); try (final ExecHarness harness = ExecHarness.harness()) { final ExecResult<ReceivedResponse> result = harness.yield(new Function<Execution,Promise<ReceivedResponse>>() { @Override public Promise<ReceivedResponse> apply(final Execution execution) { return client.get(URI.create("http://localhost:5050")); } }); final int statusCode = result.getValue().getStatusCode(); if (200 != statusCode) throw new AssertionError("ERROR: response: " + statusCode); } server.stop(); TestUtil.checkSpan(new ComponentSpanCount("netty", 2, true)); }
Example #3
Source File: RatpackCurrentTraceContext.java From ratpack-zipkin with Apache License 2.0 | 4 votes |
public RatpackCurrentTraceContext() { this(Execution::current); }
Example #4
Source File: ITZipkinHttpClientImpl.java From ratpack-zipkin with Apache License 2.0 | 4 votes |
void harnessSetup(Execution execution) { currentTraceContext = new RatpackCurrentTraceContext(() -> execution); httpTracing = HttpTracing.create(tracingBuilder(Sampler.ALWAYS_SAMPLE).build()); client = newClient(server.getPort()); }