diff --git a/servicetalk-examples/http/traffic-resilience/src/main/java/io/servicetalk/examples/http/traffic/resilience/TrafficResilienceClientBreakersExample.java b/servicetalk-examples/http/traffic-resilience/src/main/java/io/servicetalk/examples/http/traffic/resilience/TrafficResilienceClientBreakersExample.java index ab1355c9ed..3052faf055 100644 --- a/servicetalk-examples/http/traffic-resilience/src/main/java/io/servicetalk/examples/http/traffic/resilience/TrafficResilienceClientBreakersExample.java +++ b/servicetalk-examples/http/traffic-resilience/src/main/java/io/servicetalk/examples/http/traffic/resilience/TrafficResilienceClientBreakersExample.java @@ -46,7 +46,8 @@ public static void main(String[] args) throws Exception { try (BlockingHttpClient client = HttpClients.forSingleAddress("localhost", 8080) .appendClientFilter(resilienceFilter) - .build().asBlockingClient()) { + .build() + .asBlockingClient()) { // Will use breakerForPathA client.request(client.get("/A")); // Will use breakerForNonAPaths diff --git a/servicetalk-examples/http/traffic-resilience/src/main/java/io/servicetalk/examples/http/traffic/resilience/TrafficResilienceClientPeerRejectionsPassthroughExample.java b/servicetalk-examples/http/traffic-resilience/src/main/java/io/servicetalk/examples/http/traffic/resilience/TrafficResilienceClientPeerRejectionsPassthroughExample.java index 06dc292efa..97b1eaccd4 100644 --- a/servicetalk-examples/http/traffic-resilience/src/main/java/io/servicetalk/examples/http/traffic/resilience/TrafficResilienceClientPeerRejectionsPassthroughExample.java +++ b/servicetalk-examples/http/traffic-resilience/src/main/java/io/servicetalk/examples/http/traffic/resilience/TrafficResilienceClientPeerRejectionsPassthroughExample.java @@ -16,6 +16,7 @@ package io.servicetalk.examples.http.traffic.resilience; import io.servicetalk.capacity.limiter.api.CapacityLimiters; +import io.servicetalk.http.api.BlockingHttpClient; import io.servicetalk.http.netty.HttpClients; import io.servicetalk.traffic.resilience.http.ClientPeerRejectionPolicy; import io.servicetalk.traffic.resilience.http.TrafficResilienceHttpClientFilter; @@ -29,7 +30,7 @@ * client. */ public final class TrafficResilienceClientPeerRejectionsPassthroughExample { - public static void main(String[] args) { + public static void main(String[] args) throws Exception { final TrafficResilienceHttpClientFilter resilienceFilter = new TrafficResilienceHttpClientFilter.Builder(() -> CapacityLimiters.dynamicGradient().build()) .rejectionPolicy(ClientPeerRejectionPolicy.ofPassthrough(metaData -> @@ -38,8 +39,11 @@ public static void main(String[] args) { metaData.status().code() == SERVICE_UNAVAILABLE.code())) .build(); - HttpClients.forSingleAddress("localhost", 8080) + try (BlockingHttpClient client = HttpClients.forSingleAddress("localhost", 8080) .appendClientFilter(resilienceFilter) - .build(); + .build() + .asBlockingClient()) { + client.request(client.get("/foo")); + } } } diff --git a/servicetalk-examples/http/traffic-resilience/src/main/java/io/servicetalk/examples/http/traffic/resilience/TrafficResilienceClientPeerRejectionsRetryExample.java b/servicetalk-examples/http/traffic-resilience/src/main/java/io/servicetalk/examples/http/traffic/resilience/TrafficResilienceClientPeerRejectionsRetryExample.java index feedd68885..3b4e3c9413 100644 --- a/servicetalk-examples/http/traffic-resilience/src/main/java/io/servicetalk/examples/http/traffic/resilience/TrafficResilienceClientPeerRejectionsRetryExample.java +++ b/servicetalk-examples/http/traffic-resilience/src/main/java/io/servicetalk/examples/http/traffic/resilience/TrafficResilienceClientPeerRejectionsRetryExample.java @@ -16,6 +16,7 @@ package io.servicetalk.examples.http.traffic.resilience; import io.servicetalk.capacity.limiter.api.CapacityLimiters; +import io.servicetalk.http.api.BlockingHttpClient; import io.servicetalk.http.netty.HttpClients; import io.servicetalk.http.netty.RetryingHttpRequesterFilter; import io.servicetalk.traffic.resilience.http.ClientPeerRejectionPolicy; @@ -32,7 +33,7 @@ * A client which configures the resilience filters to signal an appropriate delay to the retry filter. */ public final class TrafficResilienceClientPeerRejectionsRetryExample { - public static void main(String[] args) { + public static void main(String[] args) throws Exception { final TrafficResilienceHttpClientFilter resilienceFilter = new TrafficResilienceHttpClientFilter.Builder(() -> CapacityLimiters.dynamicGradient().build()) .rejectionPolicy(ClientPeerRejectionPolicy.ofRejectionWithRetries(DEFAULT_CAPACITY_REJECTION_PREDICATE, @@ -44,9 +45,12 @@ public static void main(String[] args) { ofExponentialBackoffDeltaJitter(retry.delay(), ofMillis(500), ofSeconds(2), 2)) .build(); - HttpClients.forSingleAddress("localhost", 8080) + try (BlockingHttpClient client = HttpClients.forSingleAddress("localhost", 8080) .appendClientFilter(retryingHttpRequesterFilter) .appendClientFilter(resilienceFilter) - .build(); + .build() + .asBlockingClient()) { + client.request(client.get("/foo")); + }; } } diff --git a/servicetalk-examples/http/traffic-resilience/src/main/java/io/servicetalk/examples/http/traffic/resilience/TrafficResilienceServerClassificationExample.java b/servicetalk-examples/http/traffic-resilience/src/main/java/io/servicetalk/examples/http/traffic/resilience/TrafficResilienceServerClassificationExample.java index 279dd8fe63..470cf05f63 100644 --- a/servicetalk-examples/http/traffic-resilience/src/main/java/io/servicetalk/examples/http/traffic/resilience/TrafficResilienceServerClassificationExample.java +++ b/servicetalk-examples/http/traffic-resilience/src/main/java/io/servicetalk/examples/http/traffic/resilience/TrafficResilienceServerClassificationExample.java @@ -16,7 +16,6 @@ package io.servicetalk.examples.http.traffic.resilience; import io.servicetalk.capacity.limiter.api.CapacityLimiters; -import io.servicetalk.concurrent.api.Single; import io.servicetalk.http.netty.HttpServers; import io.servicetalk.traffic.resilience.http.TrafficResilienceHttpServiceFilter; @@ -33,7 +32,7 @@ public static void main(String[] args) throws Exception { HttpServers.forPort(8080) .appendNonOffloadingServiceFilter(resilienceFilter) - .listenAndAwait((ctx, request, responseFactory) -> Single.succeeded(responseFactory.ok())) + .listenBlockingAndAwait((ctx, request, responseFactory) -> responseFactory.ok()) .awaitShutdown(); } } diff --git a/servicetalk-examples/http/traffic-resilience/src/main/java/io/servicetalk/examples/http/traffic/resilience/TrafficResilienceServerExample.java b/servicetalk-examples/http/traffic-resilience/src/main/java/io/servicetalk/examples/http/traffic/resilience/TrafficResilienceServerExample.java index a4fd2ff59a..fddade2a66 100644 --- a/servicetalk-examples/http/traffic-resilience/src/main/java/io/servicetalk/examples/http/traffic/resilience/TrafficResilienceServerExample.java +++ b/servicetalk-examples/http/traffic-resilience/src/main/java/io/servicetalk/examples/http/traffic/resilience/TrafficResilienceServerExample.java @@ -16,7 +16,6 @@ package io.servicetalk.examples.http.traffic.resilience; import io.servicetalk.capacity.limiter.api.CapacityLimiters; -import io.servicetalk.concurrent.api.Single; import io.servicetalk.http.netty.HttpServers; import io.servicetalk.traffic.resilience.http.TrafficResilienceHttpServiceFilter; @@ -32,7 +31,7 @@ public static void main(String[] args) throws Exception { HttpServers.forPort(8080) .appendNonOffloadingServiceFilter(resilienceFilter) - .listenAndAwait((ctx, request, responseFactory) -> Single.succeeded(responseFactory.ok())) + .listenBlockingAndAwait((ctx, request, responseFactory) -> responseFactory.ok()) .awaitShutdown(); } } diff --git a/servicetalk-examples/http/traffic-resilience/src/main/java/io/servicetalk/examples/http/traffic/resilience/TrafficResilienceServerPartitionExample.java b/servicetalk-examples/http/traffic-resilience/src/main/java/io/servicetalk/examples/http/traffic/resilience/TrafficResilienceServerPartitionExample.java index 0660c73eda..38a4423de3 100644 --- a/servicetalk-examples/http/traffic-resilience/src/main/java/io/servicetalk/examples/http/traffic/resilience/TrafficResilienceServerPartitionExample.java +++ b/servicetalk-examples/http/traffic-resilience/src/main/java/io/servicetalk/examples/http/traffic/resilience/TrafficResilienceServerPartitionExample.java @@ -17,7 +17,6 @@ import io.servicetalk.capacity.limiter.api.CapacityLimiter; import io.servicetalk.capacity.limiter.api.CapacityLimiters; -import io.servicetalk.concurrent.api.Single; import io.servicetalk.http.netty.HttpServers; import io.servicetalk.traffic.resilience.http.TrafficResilienceHttpServiceFilter; @@ -38,7 +37,7 @@ public static void main(String[] args) throws Exception { HttpServers.forPort(8080) .appendNonOffloadingServiceFilter(resilienceFilter) - .listenAndAwait((ctx, request, responseFactory) -> Single.succeeded(responseFactory.ok())) + .listenBlockingAndAwait((ctx, request, responseFactory) -> responseFactory.ok()) .awaitShutdown(); } } diff --git a/servicetalk-examples/http/traffic-resilience/src/main/java/io/servicetalk/examples/http/traffic/resilience/TrafficResilienceServerQuotasExample.java b/servicetalk-examples/http/traffic-resilience/src/main/java/io/servicetalk/examples/http/traffic/resilience/TrafficResilienceServerQuotasExample.java index f4ecbd6834..3a0c3a1eef 100644 --- a/servicetalk-examples/http/traffic-resilience/src/main/java/io/servicetalk/examples/http/traffic/resilience/TrafficResilienceServerQuotasExample.java +++ b/servicetalk-examples/http/traffic-resilience/src/main/java/io/servicetalk/examples/http/traffic/resilience/TrafficResilienceServerQuotasExample.java @@ -17,7 +17,6 @@ import io.servicetalk.capacity.limiter.api.CapacityLimiter; import io.servicetalk.capacity.limiter.api.CapacityLimiters; -import io.servicetalk.concurrent.api.Single; import io.servicetalk.http.netty.HttpServers; import io.servicetalk.traffic.resilience.http.TrafficResilienceHttpServiceFilter; @@ -44,7 +43,7 @@ public static void main(String[] args) throws Exception { HttpServers.forPort(8080) .appendNonOffloadingServiceFilter(resilienceFilter) - .listenAndAwait((ctx, request, responseFactory) -> Single.succeeded(responseFactory.ok())) + .listenBlockingAndAwait((ctx, request, responseFactory) -> responseFactory.ok()) .awaitShutdown(); } } diff --git a/servicetalk-examples/http/traffic-resilience/src/main/java/io/servicetalk/examples/http/traffic/resilience/TrafficResilienceServerStopAcceptingExample.java b/servicetalk-examples/http/traffic-resilience/src/main/java/io/servicetalk/examples/http/traffic/resilience/TrafficResilienceServerStopAcceptingExample.java index acfbb35225..9951f84abc 100644 --- a/servicetalk-examples/http/traffic-resilience/src/main/java/io/servicetalk/examples/http/traffic/resilience/TrafficResilienceServerStopAcceptingExample.java +++ b/servicetalk-examples/http/traffic-resilience/src/main/java/io/servicetalk/examples/http/traffic/resilience/TrafficResilienceServerStopAcceptingExample.java @@ -16,7 +16,6 @@ package io.servicetalk.examples.http.traffic.resilience; import io.servicetalk.capacity.limiter.api.CapacityLimiters; -import io.servicetalk.concurrent.api.Single; import io.servicetalk.http.netty.HttpServers; import io.servicetalk.traffic.resilience.http.ServiceRejectionPolicy; import io.servicetalk.traffic.resilience.http.TrafficResilienceHttpServiceFilter; @@ -38,7 +37,7 @@ public static void main(String[] args) throws Exception { HttpServers.forPort(8080) .appendNonOffloadingServiceFilter(resilienceFilter) - .listenAndAwait((ctx, request, responseFactory) -> Single.succeeded(responseFactory.ok())) + .listenBlockingAndAwait((ctx, request, responseFactory) -> responseFactory.ok()) .awaitShutdown(); } } diff --git a/servicetalk-examples/http/traffic-resilience/src/main/java/io/servicetalk/examples/http/traffic/resilience/TrafficResilienceServerTerminalsExample.java b/servicetalk-examples/http/traffic-resilience/src/main/java/io/servicetalk/examples/http/traffic/resilience/TrafficResilienceServerTerminalsExample.java index 430f677798..c08ace9dd6 100644 --- a/servicetalk-examples/http/traffic-resilience/src/main/java/io/servicetalk/examples/http/traffic/resilience/TrafficResilienceServerTerminalsExample.java +++ b/servicetalk-examples/http/traffic-resilience/src/main/java/io/servicetalk/examples/http/traffic/resilience/TrafficResilienceServerTerminalsExample.java @@ -16,7 +16,6 @@ package io.servicetalk.examples.http.traffic.resilience; import io.servicetalk.capacity.limiter.api.CapacityLimiters; -import io.servicetalk.concurrent.api.Single; import io.servicetalk.http.netty.HttpServers; import io.servicetalk.traffic.resilience.http.TrafficResilienceHttpServiceFilter; @@ -41,7 +40,7 @@ public static void main(String[] args) throws Exception { HttpServers.forPort(8080) .appendNonOffloadingServiceFilter(resilienceFilter) - .listenAndAwait((ctx, request, responseFactory) -> Single.succeeded(responseFactory.ok())) + .listenBlockingAndAwait((ctx, request, responseFactory) -> responseFactory.ok()) .awaitShutdown(); } }