Search in sources :

Example 31 with HostAndPort

use of io.servicetalk.transport.api.HostAndPort in project servicetalk by apple.

the class TcpFastOpenTest method newClient.

private static BlockingHttpClient newClient(final ServerContext serverContext, final Collection<HttpProtocol> protocols, final boolean secure, @SuppressWarnings("rawtypes") final Map<SocketOption, Object> clientOptions) {
    SingleAddressHttpClientBuilder<HostAndPort, InetSocketAddress> builder = HttpClients.forSingleAddress(serverHostAndPort(serverContext)).protocols(toConfigs(protocols));
    if (secure) {
        builder.sslConfig(new ClientSslConfigBuilder(DefaultTestCerts::loadServerCAPem).sniHostname(serverPemHostname()).build());
    }
    for (@SuppressWarnings("rawtypes") Entry<SocketOption, Object> entry : clientOptions.entrySet()) {
        @SuppressWarnings("unchecked") SocketOption<Object> option = entry.getKey();
        builder.socketOption(option, entry.getValue());
    }
    return builder.buildBlocking();
}
Also used : AddressUtils.serverHostAndPort(io.servicetalk.transport.netty.internal.AddressUtils.serverHostAndPort) HostAndPort(io.servicetalk.transport.api.HostAndPort) SocketOption(java.net.SocketOption) InetSocketAddress(java.net.InetSocketAddress) ClientSslConfigBuilder(io.servicetalk.transport.api.ClientSslConfigBuilder)

Aggregations

HostAndPort (io.servicetalk.transport.api.HostAndPort)31 AddressUtils.serverHostAndPort (io.servicetalk.transport.netty.internal.AddressUtils.serverHostAndPort)25 InetSocketAddress (java.net.InetSocketAddress)22 ServerContext (io.servicetalk.transport.api.ServerContext)13 Test (org.junit.jupiter.api.Test)12 MatcherAssert.assertThat (org.hamcrest.MatcherAssert.assertThat)9 Single (io.servicetalk.concurrent.api.Single)8 StreamingHttpRequest (io.servicetalk.http.api.StreamingHttpRequest)8 StreamingHttpResponse (io.servicetalk.http.api.StreamingHttpResponse)8 AddressUtils.localAddress (io.servicetalk.transport.netty.internal.AddressUtils.localAddress)8 Completable.completed (io.servicetalk.concurrent.api.Completable.completed)7 Publisher (io.servicetalk.concurrent.api.Publisher)7 StreamingHttpClientFilterFactory (io.servicetalk.http.api.StreamingHttpClientFilterFactory)7 ExecutionException (java.util.concurrent.ExecutionException)7 Publisher.from (io.servicetalk.concurrent.api.Publisher.from)6 BlockingQueue (java.util.concurrent.BlockingQueue)6 Matchers.notNullValue (org.hamcrest.Matchers.notNullValue)6 Assertions.assertThrows (org.junit.jupiter.api.Assertions.assertThrows)6 Greeter (io.grpc.examples.helloworld.Greeter)5 StreamingHttpClient (io.servicetalk.http.api.StreamingHttpClient)5