Search in sources :

Example 1 with HttpClients.forResolvedAddress

use of io.servicetalk.http.netty.HttpClients.forResolvedAddress in project servicetalk by apple.

the class AbstractHttpServiceAsyncContextTest method connectionAcceptorContextDoesNotLeak.

final void connectionAcceptorContextDoesNotLeak(boolean serverUseImmediate) throws Exception {
    try (ServerContext ctx = serverWithEmptyAsyncContextService(HttpServers.forAddress(localAddress(0)).appendConnectionAcceptorFilter(original -> new DelegatingConnectionAcceptor(context -> {
        AsyncContext.put(K1, "v1");
        return completed();
    })), serverUseImmediate);
        StreamingHttpClient client = HttpClients.forResolvedAddress(serverHostAndPort(ctx)).buildStreaming();
        StreamingHttpConnection connection = client.reserveConnection(client.get("/")).toFuture().get()) {
        makeClientRequestWithId(connection, "1");
        makeClientRequestWithId(connection, "2");
    }
}
Also used : StreamingHttpResponse(io.servicetalk.http.api.StreamingHttpResponse) Assertions.assertNull(org.junit.jupiter.api.Assertions.assertNull) StreamingHttpServiceFilterFactory(io.servicetalk.http.api.StreamingHttpServiceFilterFactory) CharSequences.newAsciiString(io.servicetalk.buffer.api.CharSequences.newAsciiString) Thread.currentThread(java.lang.Thread.currentThread) AtomicReference(java.util.concurrent.atomic.AtomicReference) Supplier(java.util.function.Supplier) Key.newKey(io.servicetalk.context.api.ContextMap.Key.newKey) StreamingHttpServiceFilter(io.servicetalk.http.api.StreamingHttpServiceFilter) HttpServiceContext(io.servicetalk.http.api.HttpServiceContext) AsyncContext(io.servicetalk.concurrent.api.AsyncContext) StreamingHttpClient(io.servicetalk.http.api.StreamingHttpClient) Single.succeeded(io.servicetalk.concurrent.api.Single.succeeded) StreamingHttpRequest(io.servicetalk.http.api.StreamingHttpRequest) AddressUtils.serverHostAndPort(io.servicetalk.transport.netty.internal.AddressUtils.serverHostAndPort) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) HttpServerBuilder(io.servicetalk.http.api.HttpServerBuilder) ExecutorService(java.util.concurrent.ExecutorService) Nullable(javax.annotation.Nullable) CyclicBarrier(java.util.concurrent.CyclicBarrier) AddressUtils.localAddress(io.servicetalk.transport.netty.internal.AddressUtils.localAddress) Matchers.empty(org.hamcrest.Matchers.empty) ServerContext(io.servicetalk.transport.api.ServerContext) HttpProtocolConfigs.h1(io.servicetalk.http.netty.HttpProtocolConfigs.h1) StreamingHttpConnection(io.servicetalk.http.api.StreamingHttpConnection) Single.defer(io.servicetalk.concurrent.api.Single.defer) PublisherSource(io.servicetalk.concurrent.PublisherSource) Single(io.servicetalk.concurrent.api.Single) OK(io.servicetalk.http.api.HttpResponseStatus.OK) InetSocketAddress(java.net.InetSocketAddress) Executors(java.util.concurrent.Executors) HttpClients.forResolvedAddress(io.servicetalk.http.netty.HttpClients.forResolvedAddress) SingleAddressHttpClientBuilder(io.servicetalk.http.api.SingleAddressHttpClientBuilder) Test(org.junit.jupiter.api.Test) ExecutionException(java.util.concurrent.ExecutionException) CountDownLatch(java.util.concurrent.CountDownLatch) ContextMap(io.servicetalk.context.api.ContextMap) DelegatingConnectionAcceptor(io.servicetalk.transport.api.DelegatingConnectionAcceptor) Completable.completed(io.servicetalk.concurrent.api.Completable.completed) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) StreamingHttpResponseFactory(io.servicetalk.http.api.StreamingHttpResponseFactory) Queue(java.util.Queue) HostAndPort(io.servicetalk.transport.api.HostAndPort) ConcurrentLinkedQueue(java.util.concurrent.ConcurrentLinkedQueue) HttpExecutionStrategies.offloadNever(io.servicetalk.http.api.HttpExecutionStrategies.offloadNever) StreamingHttpClient(io.servicetalk.http.api.StreamingHttpClient) ServerContext(io.servicetalk.transport.api.ServerContext) DelegatingConnectionAcceptor(io.servicetalk.transport.api.DelegatingConnectionAcceptor) StreamingHttpConnection(io.servicetalk.http.api.StreamingHttpConnection)

Aggregations

CharSequences.newAsciiString (io.servicetalk.buffer.api.CharSequences.newAsciiString)1 PublisherSource (io.servicetalk.concurrent.PublisherSource)1 AsyncContext (io.servicetalk.concurrent.api.AsyncContext)1 Completable.completed (io.servicetalk.concurrent.api.Completable.completed)1 Single (io.servicetalk.concurrent.api.Single)1 Single.defer (io.servicetalk.concurrent.api.Single.defer)1 Single.succeeded (io.servicetalk.concurrent.api.Single.succeeded)1 ContextMap (io.servicetalk.context.api.ContextMap)1 Key.newKey (io.servicetalk.context.api.ContextMap.Key.newKey)1 HttpExecutionStrategies.offloadNever (io.servicetalk.http.api.HttpExecutionStrategies.offloadNever)1 OK (io.servicetalk.http.api.HttpResponseStatus.OK)1 HttpServerBuilder (io.servicetalk.http.api.HttpServerBuilder)1 HttpServiceContext (io.servicetalk.http.api.HttpServiceContext)1 SingleAddressHttpClientBuilder (io.servicetalk.http.api.SingleAddressHttpClientBuilder)1 StreamingHttpClient (io.servicetalk.http.api.StreamingHttpClient)1 StreamingHttpConnection (io.servicetalk.http.api.StreamingHttpConnection)1 StreamingHttpRequest (io.servicetalk.http.api.StreamingHttpRequest)1 StreamingHttpResponse (io.servicetalk.http.api.StreamingHttpResponse)1 StreamingHttpResponseFactory (io.servicetalk.http.api.StreamingHttpResponseFactory)1 StreamingHttpServiceFilter (io.servicetalk.http.api.StreamingHttpServiceFilter)1