Class SingleConnection<StreamRequestT,StreamResponseT,ClientResponseT>
- java.lang.Object
-
- com.google.cloud.pubsublite.internal.wire.SingleConnection<StreamRequestT,StreamResponseT,ClientResponseT>
-
- Type Parameters:
StreamRequestT- The request type sent on the stream.StreamResponseT- The response type sent from the stream.ClientResponseT- The response type sent to the client.
- All Implemented Interfaces:
com.google.api.gax.rpc.ResponseObserver<StreamResponseT>,AutoCloseable
- Direct Known Subclasses:
ConnectedAssignerImpl,ConnectedCommitterImpl
public abstract class SingleConnection<StreamRequestT,StreamResponseT,ClientResponseT> extends Object implements com.google.api.gax.rpc.ResponseObserver<StreamResponseT>, AutoCloseable
A SingleConnection handles the state for a stream with an initial connection request that may only be sent once and needs to wait for a response before sending other requests.
-
-
Field Summary
Fields Modifier and Type Field Description protected static DurationDEFAULT_STREAM_IDLE_TIMEOUT
-
Constructor Summary
Constructors Modifier Constructor Description protectedSingleConnection(StreamFactory<StreamRequestT,StreamResponseT> streamFactory, com.google.api.gax.rpc.ResponseObserver<ClientResponseT> clientStream)protectedSingleConnection(StreamFactory<StreamRequestT,StreamResponseT> streamFactory, com.google.api.gax.rpc.ResponseObserver<ClientResponseT> clientStream, Duration streamIdleTimeout)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidclose()protected abstract voidhandleStreamResponse(StreamResponseT response)protected voidinitialize(StreamRequestT initialRequest)voidonComplete()voidonError(Throwable t)voidonResponse(StreamResponseT response)voidonStart(com.google.api.gax.rpc.StreamController streamController)protected voidsendToClient(ClientResponseT response)protected voidsendToStream(StreamRequestT request)protected voidsetError(CheckedApiException error)
-
-
-
Field Detail
-
DEFAULT_STREAM_IDLE_TIMEOUT
protected static final Duration DEFAULT_STREAM_IDLE_TIMEOUT
-
-
Constructor Detail
-
SingleConnection
protected SingleConnection(StreamFactory<StreamRequestT,StreamResponseT> streamFactory, com.google.api.gax.rpc.ResponseObserver<ClientResponseT> clientStream, Duration streamIdleTimeout)
-
SingleConnection
protected SingleConnection(StreamFactory<StreamRequestT,StreamResponseT> streamFactory, com.google.api.gax.rpc.ResponseObserver<ClientResponseT> clientStream)
-
-
Method Detail
-
handleStreamResponse
protected abstract void handleStreamResponse(StreamResponseT response) throws CheckedApiException
- Throws:
CheckedApiException
-
initialize
protected void initialize(StreamRequestT initialRequest)
-
sendToStream
protected void sendToStream(StreamRequestT request)
-
sendToClient
protected void sendToClient(ClientResponseT response)
-
setError
protected void setError(CheckedApiException error)
-
close
public void close()
- Specified by:
closein interfaceAutoCloseable
-
onStart
public void onStart(com.google.api.gax.rpc.StreamController streamController)
- Specified by:
onStartin interfacecom.google.api.gax.rpc.ResponseObserver<StreamRequestT>
-
onResponse
public void onResponse(StreamResponseT response)
- Specified by:
onResponsein interfacecom.google.api.gax.rpc.ResponseObserver<StreamRequestT>
-
onError
public void onError(Throwable t)
- Specified by:
onErrorin interfacecom.google.api.gax.rpc.ResponseObserver<StreamRequestT>
-
onComplete
public void onComplete()
- Specified by:
onCompletein interfacecom.google.api.gax.rpc.ResponseObserver<StreamRequestT>
-
-