Class OperationResponse<ResponseType extends EventStreamJsonMessage,StreamRequestType extends EventStreamJsonMessage>
- java.lang.Object
-
- software.amazon.awssdk.eventstreamrpc.OperationResponse<ResponseType,StreamRequestType>
-
- Type Parameters:
ResponseType
- The response typeStreamRequestType
- The stream response type
- All Implemented Interfaces:
AutoCloseable
,StreamEventPublisher<StreamRequestType>
,StreamResponse<ResponseType,StreamRequestType>
public class OperationResponse<ResponseType extends EventStreamJsonMessage,StreamRequestType extends EventStreamJsonMessage> extends Object implements StreamResponse<ResponseType,StreamRequestType>, AutoCloseable
Underlying type for operation response handling. Enables publishing on stream operations from client, closing of any open stream, and retrieval of response. Specific generated operation response handlers are usually simple wrappers with the generic types specified
-
-
Constructor Summary
Constructors Constructor Description OperationResponse(OperationModelContext<ResponseType,?,StreamRequestType,?> operationModelContext, software.amazon.awssdk.crt.eventstream.ClientConnectionContinuation continuation, CompletableFuture<ResponseType> responseFuture, CompletableFuture<Void> requestFlushFuture)
Creates a new OperationResponse from the given data
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
CompletableFuture<Void>
closeStream()
Initiate a close on the event stream from the client side.CompletableFuture<Void>
getRequestFlushFuture()
Returns the request flush future to useCompletableFuture<ResponseType>
getResponse()
Get the response completable future to wait on the initial response if there is one.boolean
isClosed()
Checks if the stream is closedCompletableFuture<Void>
sendStreamEvent(StreamRequestType streamEvent)
Publish stream events on an open operation's event stream.
-
-
-
Constructor Detail
-
OperationResponse
public OperationResponse(OperationModelContext<ResponseType,?,StreamRequestType,?> operationModelContext, software.amazon.awssdk.crt.eventstream.ClientConnectionContinuation continuation, CompletableFuture<ResponseType> responseFuture, CompletableFuture<Void> requestFlushFuture)
Creates a new OperationResponse from the given data- Parameters:
operationModelContext
- The operation model context to usecontinuation
- The continuation to useresponseFuture
- The response future to userequestFlushFuture
- The request flush future to use
-
-
Method Detail
-
getRequestFlushFuture
public final CompletableFuture<Void> getRequestFlushFuture()
Returns the request flush future to use- Specified by:
getRequestFlushFuture
in interfaceStreamResponse<ResponseType extends EventStreamJsonMessage,StreamRequestType extends EventStreamJsonMessage>
- Returns:
- The request flush future to use
-
getResponse
public CompletableFuture<ResponseType> getResponse()
Get the response completable future to wait on the initial response if there is one. May throw exception if requestFlushFuture throws an exception and will block if requestFlush has not completed.- Specified by:
getResponse
in interfaceStreamResponse<ResponseType extends EventStreamJsonMessage,StreamRequestType extends EventStreamJsonMessage>
- Returns:
- the response completable future to wait on the initial response if there is one.
-
sendStreamEvent
public CompletableFuture<Void> sendStreamEvent(StreamRequestType streamEvent)
Publish stream events on an open operation's event stream.- Specified by:
sendStreamEvent
in interfaceStreamEventPublisher<ResponseType extends EventStreamJsonMessage>
- Parameters:
streamEvent
- event to publish- Returns:
- Completable future indicating flush of the event over the stream
-
closeStream
public CompletableFuture<Void> closeStream()
Initiate a close on the event stream from the client side.- Specified by:
closeStream
in interfaceStreamEventPublisher<ResponseType extends EventStreamJsonMessage>
- Returns:
- A future that completes when the event stream is closed
-
isClosed
public boolean isClosed()
Checks if the stream is closed- Specified by:
isClosed
in interfaceStreamResponse<ResponseType extends EventStreamJsonMessage,StreamRequestType extends EventStreamJsonMessage>
- Returns:
- True if the stream is closed
-
close
public void close() throws Exception
- Specified by:
close
in interfaceAutoCloseable
- Throws:
Exception
-
-