Class DefaultEventStreamResponseHandlerBuilder<ResponseT,EventT,SubBuilderT>
- java.lang.Object
-
- software.amazon.awssdk.awscore.eventstream.DefaultEventStreamResponseHandlerBuilder<ResponseT,EventT,SubBuilderT>
-
- Type Parameters:
ResponseT
- Type of POJO response.EventT
- Type of event being published.SubBuilderT
- Subtype of builder class for method chaining.
- All Implemented Interfaces:
EventStreamResponseHandler.Builder<ResponseT,EventT,SubBuilderT>
public abstract class DefaultEventStreamResponseHandlerBuilder<ResponseT,EventT,SubBuilderT> extends Object implements EventStreamResponseHandler.Builder<ResponseT,EventT,SubBuilderT>
Base class for event stream response handler builders.
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
DefaultEventStreamResponseHandlerBuilder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SubBuilderT
onComplete(Runnable onComplete)
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>> eventSubscriber)
Subscriber that will subscribe to theSdkPublisher
of events.
-
-
-
Method Detail
-
onResponse
public SubBuilderT onResponse(Consumer<ResponseT> responseConsumer)
Description copied from interface:EventStreamResponseHandler.Builder
Callback to invoke when the initial response is received.- Specified by:
onResponse
in interfaceEventStreamResponseHandler.Builder<ResponseT,EventT,SubBuilderT>
- Parameters:
responseConsumer
- Callback that will process the initial response.- Returns:
- This builder for method chaining.
-
onError
public SubBuilderT onError(Consumer<Throwable> consumer)
Description copied from interface:EventStreamResponseHandler.Builder
Callback to invoke in the event on an error.- Specified by:
onError
in interfaceEventStreamResponseHandler.Builder<ResponseT,EventT,SubBuilderT>
- Parameters:
consumer
- Callback that will process any error that occurs.- Returns:
- This builder for method chaining.
-
onComplete
public SubBuilderT onComplete(Runnable onComplete)
Description copied from interface:EventStreamResponseHandler.Builder
Action to invoke when the event stream completes. This will only be invoked when all events are being received.- Specified by:
onComplete
in interfaceEventStreamResponseHandler.Builder<ResponseT,EventT,SubBuilderT>
- Parameters:
onComplete
- Action to run on the completion of the event stream.- Returns:
- This builder for method chaining.
-
subscriber
public SubBuilderT subscriber(Supplier<org.reactivestreams.Subscriber<EventT>> eventSubscriber)
Description copied from interface:EventStreamResponseHandler.Builder
Subscriber that will subscribe to theSdkPublisher
of events. Subscriber must be provided.- Specified by:
subscriber
in interfaceEventStreamResponseHandler.Builder<ResponseT,EventT,SubBuilderT>
- Parameters:
eventSubscriber
- Supplier for a subscriber that will be subscribed to the publisher of events.- Returns:
- This builder for method chaining.
-
subscriber
public SubBuilderT subscriber(Consumer<EventT> eventConsumer)
Description copied from interface:EventStreamResponseHandler.Builder
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 usingEventStreamResponseHandler.Builder.subscriber(Supplier)
instead.- Specified by:
subscriber
in interfaceEventStreamResponseHandler.Builder<ResponseT,EventT,SubBuilderT>
- Parameters:
eventConsumer
- Consumer that will process incoming events.- Returns:
- This builder for method chaining.
-
onEventStream
public SubBuilderT onEventStream(Consumer<SdkPublisher<EventT>> onSubscribe)
Description copied from interface:EventStreamResponseHandler.Builder
Callback to invoke when theSdkPublisher
is available. This callback must subscribe to the given publisher. This method should not be used withEventStreamResponseHandler.Builder.subscriber(Supplier)
or any of it's overloads.- Specified by:
onEventStream
in interfaceEventStreamResponseHandler.Builder<ResponseT,EventT,SubBuilderT>
- Parameters:
onSubscribe
- Callback that will subscribe to theSdkPublisher
.- Returns:
- This builder for method chaining.
-
publisherTransformer
public SubBuilderT publisherTransformer(Function<SdkPublisher<EventT>,SdkPublisher<EventT>> publisherTransformer)
Description copied from interface:EventStreamResponseHandler.Builder
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.- Specified by:
publisherTransformer
in interfaceEventStreamResponseHandler.Builder<ResponseT,EventT,SubBuilderT>
- Parameters:
publisherTransformer
- Function that returns a newSdkPublisher
with augmented behavior.- Returns:
- This builder for method chaining.
-
-