Package com.google.api.gax.retrying
Class SimpleStreamResumptionStrategy<RequestT,ResponseT>
- java.lang.Object
-
- com.google.api.gax.retrying.SimpleStreamResumptionStrategy<RequestT,ResponseT>
-
- All Implemented Interfaces:
StreamResumptionStrategy<RequestT,ResponseT>
public final class SimpleStreamResumptionStrategy<RequestT,ResponseT> extends Object implements StreamResumptionStrategy<RequestT,ResponseT>
Simplest implementation of aStreamResumptionStrategywhich returns the initial request for unstarted streams.
-
-
Constructor Summary
Constructors Constructor Description SimpleStreamResumptionStrategy()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancanResume()If a resume request can be created.StreamResumptionStrategy<RequestT,ResponseT>createNew()Creates a new instance of this StreamResumptionStrategy without accumulated stateRequestTgetResumeRequest(RequestT originalRequest)Called when a stream needs to be restarted, the implementation should generate a request that will yield a new stream whose first response would come right after the last response received by processResponse.ResponseTprocessResponse(ResponseT response)Called by theServerStreamingAttemptCallablewhen a response has been successfully received.
-
-
-
Method Detail
-
createNew
public StreamResumptionStrategy<RequestT,ResponseT> createNew()
Description copied from interface:StreamResumptionStrategyCreates a new instance of this StreamResumptionStrategy without accumulated state- Specified by:
createNewin interfaceStreamResumptionStrategy<RequestT,ResponseT>
-
processResponse
public ResponseT processResponse(ResponseT response)
Description copied from interface:StreamResumptionStrategyCalled by theServerStreamingAttemptCallablewhen a response has been successfully received. This method accomplishes two goals:- It allows the strategy implementation to update its internal state so that it can compose the resume request
- It allows the strategy to alter the incoming responses to adjust for after resume. For example, if the responses are numbered sequentially from the start of the stream, upon resume, the strategy could rewrite the messages to continue the sequence from where it left off. Please note that all messages (even for the first attempt) will be passed through this method.
- Specified by:
processResponsein interfaceStreamResumptionStrategy<RequestT,ResponseT>
-
getResumeRequest
public RequestT getResumeRequest(RequestT originalRequest)
Description copied from interface:StreamResumptionStrategyCalled when a stream needs to be restarted, the implementation should generate a request that will yield a new stream whose first response would come right after the last response received by processResponse.- Specified by:
getResumeRequestin interfaceStreamResumptionStrategy<RequestT,ResponseT>- Returns:
- A request that can be used to resume the stream.
-
canResume
public boolean canResume()
Description copied from interface:StreamResumptionStrategyIf a resume request can be created.- Specified by:
canResumein interfaceStreamResumptionStrategy<RequestT,ResponseT>
-
-