Interface EventStreamResponseHandler.Builder<ResponseT,EventT,SubBuilderT>
-
- All Known Implementing Classes:
DefaultEventStreamResponseHandlerBuilder
- Enclosing interface:
- EventStreamResponseHandler<ResponseT,EventT>
public static interface EventStreamResponseHandler.Builder<ResponseT,EventT,SubBuilderT>
Base builder for sub-interfaces ofEventStreamResponseHandler
.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description SubBuilderT
onComplete(Runnable runnable)
Action to invoke when the event stream completes.SubBuilderT
onError(Consumer<Throwable> consumer)
Callback to invoke in the event on an error.SubBuilderT
onEventStream(Consumer<SdkPublisher<EventT>> onSubscribe)
Callback to invoke when theSdkPublisher
is available.SubBuilderT
onResponse(Consumer<ResponseT> responseConsumer)
Callback to invoke when the initial response is received.SubBuilderT
publisherTransformer(Function<SdkPublisher<EventT>,SdkPublisher<EventT>> publisherTransformer)
Allows for optional transformation of the publisher of events before subscribing.SubBuilderT
subscriber(Consumer<EventT> eventConsumer)
Sets the subscriber to theSdkPublisher
of events.SubBuilderT
subscriber(Supplier<org.reactivestreams.Subscriber<EventT>> eventSubscriberSupplier)
Subscriber that will subscribe to theSdkPublisher
of events.
-
-
-
Method Detail
-
onResponse
SubBuilderT onResponse(Consumer<ResponseT> responseConsumer)
Callback to invoke when the initial response is received.- Parameters:
responseConsumer
- Callback that will process the initial response.- Returns:
- This builder for method chaining.
-
onError
SubBuilderT onError(Consumer<Throwable> consumer)
Callback to invoke in the event on an error.- Parameters:
consumer
- Callback that will process any error that occurs.- Returns:
- This builder for method chaining.
-
onComplete
SubBuilderT onComplete(Runnable runnable)
Action to invoke when the event stream completes. This will only be invoked when all events are being received.- Parameters:
runnable
- Action to run on the completion of the event stream.- Returns:
- This builder for method chaining.
-
subscriber
SubBuilderT subscriber(Supplier<org.reactivestreams.Subscriber<EventT>> eventSubscriberSupplier)
Subscriber that will subscribe to theSdkPublisher
of events. Subscriber must be provided.- Parameters:
eventSubscriberSupplier
- Supplier for a subscriber that will be subscribed to the publisher of events.- Returns:
- This builder for method chaining.
-
subscriber
SubBuilderT subscriber(Consumer<EventT> eventConsumer)
Sets the subscriber to theSdkPublisher
of events. The given consumer will be called for each event received by the publisher. Events are requested sequentially after each event is processed. If you need more control over the backpressure strategy consider usingsubscriber(Supplier)
instead.- Parameters:
eventConsumer
- Consumer that will process incoming events.- Returns:
- This builder for method chaining.
-
onEventStream
SubBuilderT onEventStream(Consumer<SdkPublisher<EventT>> onSubscribe)
Callback to invoke when theSdkPublisher
is available. This callback must subscribe to the given publisher. This method should not be used withsubscriber(Supplier)
or any of it's overloads.- Parameters:
onSubscribe
- Callback that will subscribe to theSdkPublisher
.- Returns:
- This builder for method chaining.
-
publisherTransformer
SubBuilderT publisherTransformer(Function<SdkPublisher<EventT>,SdkPublisher<EventT>> publisherTransformer)
Allows for optional transformation of the publisher of events before subscribing. This transformation must return aSdkPublisher
of the same type so methods likeSdkPublisher.map(Function)
andSdkPublisher.buffer(int)
that change the type cannot be used with this method.- Parameters:
publisherTransformer
- Function that returns a newSdkPublisher
with augmented behavior.- Returns:
- This builder for method chaining.
-
-