public class NettyAsyncHttpClientBuilder extends Object
NettyAsyncHttpClient.
Building a new HttpClient instance
HttpClientclient = newNettyAsyncHttpClientBuilder() .port(8080) .wiretap(true) .build();
NettyAsyncHttpClient,
HttpClient| Constructor and Description |
|---|
NettyAsyncHttpClientBuilder()
Creates a new builder instance, where a builder is capable of generating multiple instances of
NettyAsyncHttpClient. |
NettyAsyncHttpClientBuilder(reactor.netty.http.client.HttpClient nettyHttpClient)
Creates a new builder instance, where a builder is capable of generating multiple instances of
NettyAsyncHttpClient based on the provided reactor netty HttpClient. |
| Modifier and Type | Method and Description |
|---|---|
com.azure.core.http.HttpClient |
build()
Creates a new Netty-backed
HttpClient instance on every call, using the
configuration set in the builder at the time of the build method call. |
NettyAsyncHttpClientBuilder |
connectionProvider(reactor.netty.resources.ConnectionProvider connectionProvider)
Sets the connection provider.
|
NettyAsyncHttpClientBuilder |
disableBufferCopy(boolean disableBufferCopy)
Disables deep copy of response
ByteBuffer into a heap location that is managed by this client as
opposed to the underlying netty library which may use direct buffer pool. |
NettyAsyncHttpClientBuilder |
nioEventLoopGroup(NioEventLoopGroup nioEventLoopGroup)
Sets the NIO event loop group that will be used to run IO loops.
|
NettyAsyncHttpClientBuilder |
port(int port)
Sets the port which this client should connect, which by default will be set to port 80.
|
NettyAsyncHttpClientBuilder |
proxy(com.azure.core.http.ProxyOptions proxyOptions)
Sets the
proxy options that the client will use. |
NettyAsyncHttpClientBuilder |
wiretap(boolean enableWiretap)
Enables the Netty wiretap feature.
|
public NettyAsyncHttpClientBuilder()
NettyAsyncHttpClient.public NettyAsyncHttpClientBuilder(reactor.netty.http.client.HttpClient nettyHttpClient)
NettyAsyncHttpClient based on the provided reactor netty HttpClient.
// Creates a reactor-netty client with netty logging enabled. reactor.netty.http.client.HttpClientbaseHttpClient = reactor.netty.http.client.HttpClient.create() .tcpConfiguration(tcp -> tcp.bootstrap(b -> b.handler(newLoggingHandler(LogLevel.INFO)))); // Create an HttpClient based on above reactor-netty client and configure EventLoop count.HttpClientclient = newNettyAsyncHttpClientBuilder(baseHttpClient) .nioEventLoopGroup(newNioEventLoopGroup(5)) .build();
nettyHttpClient - base reactor netty HttpClientpublic com.azure.core.http.HttpClient build()
HttpClient instance on every call, using the
configuration set in the builder at the time of the build method call.HttpClient instance.IllegalStateException - If the builder is configured to use an unknown proxy type.public NettyAsyncHttpClientBuilder connectionProvider(reactor.netty.resources.ConnectionProvider connectionProvider)
connectionProvider - the connection providerNettyAsyncHttpClientBuilder objectpublic NettyAsyncHttpClientBuilder proxy(com.azure.core.http.ProxyOptions proxyOptions)
proxy options that the client will use.
Code Samples
HttpClientclient = newNettyAsyncHttpClientBuilder() .proxy(newProxyOptions(ProxyOptions.Type.HTTP, newInetSocketAddress("<proxy-host>", 8888))) .build();
proxyOptions - The proxy configuration to use.public NettyAsyncHttpClientBuilder wiretap(boolean enableWiretap)
enableWiretap - Flag indicating wiretap statuspublic NettyAsyncHttpClientBuilder port(int port)
port - The port to connect to.public NettyAsyncHttpClientBuilder nioEventLoopGroup(NioEventLoopGroup nioEventLoopGroup)
Code Samples
int threadCount = 5;HttpClientclient = newNettyAsyncHttpClientBuilder() .nioEventLoopGroup(newNioEventLoopGroup(threadCount)) .build();
nioEventLoopGroup - The NioEventLoopGroup that will run IO loops.public NettyAsyncHttpClientBuilder disableBufferCopy(boolean disableBufferCopy)
ByteBuffer into a heap location that is managed by this client as
opposed to the underlying netty library which may use direct buffer pool.
ByteBuffer
upon the return of onNext(). So, users should ensure they process the ByteBuffer immediately
and then return.
HttpClientclient = newNettyAsyncHttpClientBuilder() .port(8080) .disableBufferCopy(true) .build(); client.send(httpRequest) .flatMapMany(response -> response.getBody()) .map(byteBuffer -> completeProcessingByteBuffer(byteBuffer)) .subscribe();
disableBufferCopy - If set to true, the client built from this builder will not deep-copy
response ByteBuffers.NettyAsyncHttpClientBuilder object.Copyright © 2020 Microsoft Corporation. All rights reserved.