@Prototype @Requires(classes=com.netflix.client.config.IClientConfig.class) @Primary @Replaces(value=DefaultHttpClient.class) public class RibbonRxHttpClient extends DefaultHttpClient
DefaultHttpClient
adapted to Ribbon.DefaultHttpClient.HttpClientInitializer, DefaultHttpClient.NettyRequestWriter
bootstrap, byteBufferFactory, group, HANDLER_AGGREGATOR, HANDLER_CHUNK, HANDLER_DECODER, HANDLER_STREAM, mediaTypeCodecRegistry
DEFAULT_ERROR_TYPE
Constructor and Description |
---|
RibbonRxHttpClient(LoadBalancer loadBalancer,
HttpClientConfiguration configuration,
String contextPath,
ThreadFactory threadFactory,
NettyClientSslBuilder nettyClientSslBuilder,
MediaTypeCodecRegistry codecRegistry,
AnnotationMetadataResolver annotationMetadataResolver,
List<HttpClientFilter> filters,
List<RibbonExecutionListenerAdapter> executionListeners)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
protected <O> com.netflix.loadbalancer.reactive.LoadBalancerCommand<O> |
buildLoadBalancerCommand()
Build the command using the load balancer builder.
|
protected void |
configure(BeanContext beanContext)
Configure this client for the active bean context.
|
<I> io.reactivex.Flowable<ByteBuffer<?>> |
dataStream(HttpRequest<I> request)
Request a stream of data where each emitted item is a
ByteBuffer instance. |
<I,O,E> io.reactivex.Flowable<HttpResponse<O>> |
exchange(HttpRequest<I> request,
Argument<O> bodyType,
Argument<E> errorType)
Perform an HTTP request for the given request object emitting the full HTTP response from returned
Publisher and converting the response body to the specified type. |
<I> io.reactivex.Flowable<HttpResponse<ByteBuffer<?>>> |
exchangeStream(HttpRequest<I> request)
Requests a stream data where each emitted item is a
ByteBuffer wrapped in the HttpResponse object
(which remains the same for each emitted item). |
Optional<RibbonLoadBalancer> |
getLoadBalancer() |
<I,O> io.reactivex.Flowable<O> |
jsonStream(HttpRequest<I> request,
Argument<O> type)
Perform an HTTP request and receive data as a stream of JSON objects as they become available without blocking.
|
applyFilterToResponsePublisher, buildDataStreamPublisher, buildExchangePublisher, buildExchangeStreamPublisher, buildJsonStreamPublisher, buildNettyRequest, buildSslContext, buildStreamExchange, close, closeChannelAsync, configureProxy, connect, connect, createEventLoopGroup, doConnect, doConnect, doConnect, eventStream, eventStream, getConfiguration, getLoadBalancerDiscriminator, getLog, getMediaTypeCodecRegistry, isRunning, jsonStream, jsonStream, resolveFilters, resolveRequestURI, resolveRequestURI, setClientIdentifiers, setClientIdentifiers, setMediaTypeCodecRegistry, start, stop, toBlocking
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
connect, connect
create
exchange, exchange, exchange, exchange, exchange, retrieve, retrieve, retrieve, retrieve, retrieve
refresh
eventStream, eventStream, eventStream
@Inject public RibbonRxHttpClient(@Parameter LoadBalancer loadBalancer, @Parameter HttpClientConfiguration configuration, @Parameter @Nullable String contextPath, @Nullable ThreadFactory threadFactory, NettyClientSslBuilder nettyClientSslBuilder, MediaTypeCodecRegistry codecRegistry, @Nullable AnnotationMetadataResolver annotationMetadataResolver, List<HttpClientFilter> filters, List<RibbonExecutionListenerAdapter> executionListeners)
loadBalancer
- loadBalancerconfiguration
- configurationcontextPath
- contextPaththreadFactory
- threadFactorynettyClientSslBuilder
- nettyClientSslBuildercodecRegistry
- codecRegistryexecutionListeners
- executionListenersannotationMetadataResolver
- annotationMetadataResolverfilters
- filters@Inject protected void configure(BeanContext beanContext)
DefaultHttpClient
configure
in class DefaultHttpClient
beanContext
- The bean contextpublic Optional<RibbonLoadBalancer> getLoadBalancer()
RibbonLoadBalancer
if one is configured for this clientpublic <I,O,E> io.reactivex.Flowable<HttpResponse<O>> exchange(HttpRequest<I> request, Argument<O> bodyType, Argument<E> errorType)
HttpClient
Perform an HTTP request for the given request object emitting the full HTTP response from returned
Publisher
and converting the response body to the specified type.
This method will send a Content-Length
header and except a content length header the response and is
designed for simple non-streaming exchanges of data
By default the exchange Content-Type
is application/json, unless otherwise specified in the passed
HttpRequest
exchange
in interface HttpClient
exchange
in interface RxHttpClient
exchange
in class DefaultHttpClient
I
- The request body typeO
- The response body typeE
- The error typerequest
- The HttpRequest
to executebodyType
- The body typeerrorType
- The error typePublisher
that emits the full HttpResponse
objectpublic <I> io.reactivex.Flowable<HttpResponse<ByteBuffer<?>>> exchangeStream(HttpRequest<I> request)
StreamingHttpClient
ByteBuffer
wrapped in the HttpResponse
object
(which remains the same for each emitted item).exchangeStream
in interface RxStreamingHttpClient
exchangeStream
in interface StreamingHttpClient
exchangeStream
in class DefaultHttpClient
I
- The request body typerequest
- The HttpRequest
Publisher
that emits a stream of ByteBuffer
instances wrapped by a HttpResponse
public <I> io.reactivex.Flowable<ByteBuffer<?>> dataStream(HttpRequest<I> request)
StreamingHttpClient
ByteBuffer
instance.dataStream
in interface RxStreamingHttpClient
dataStream
in interface StreamingHttpClient
dataStream
in class DefaultHttpClient
I
- The request body typerequest
- The requestPublisher
that emits a stream of ByteBuffer
instancespublic <I,O> io.reactivex.Flowable<O> jsonStream(HttpRequest<I> request, Argument<O> type)
StreamingHttpClient
Perform an HTTP request and receive data as a stream of JSON objects as they become available without blocking.
The downstream Subscriber
can regulate demand via the subscription. Incoming data
is buffered.
jsonStream
in interface RxStreamingHttpClient
jsonStream
in interface StreamingHttpClient
jsonStream
in class DefaultHttpClient
I
- The request body typeO
- The response typerequest
- The HttpRequest
to executetype
- The type of object to convert the JSON intoPublisher
that emits the full HttpResponse
objectprotected <O> com.netflix.loadbalancer.reactive.LoadBalancerCommand<O> buildLoadBalancerCommand()
O
- entity type of the command