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 Duration
DEFAULT_STREAM_IDLE_TIMEOUT
-
Constructor Summary
Constructors Modifier Constructor Description protected
SingleConnection(StreamFactory<StreamRequestT,StreamResponseT> streamFactory, com.google.api.gax.rpc.ResponseObserver<ClientResponseT> clientStream)
protected
SingleConnection(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 void
close()
protected abstract void
handleStreamResponse(StreamResponseT response)
protected void
initialize(StreamRequestT initialRequest)
void
onComplete()
void
onError(Throwable t)
void
onResponse(StreamResponseT response)
void
onStart(com.google.api.gax.rpc.StreamController streamController)
protected void
sendToClient(ClientResponseT response)
protected void
sendToStream(StreamRequestT request)
protected void
setError(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:
close
in interfaceAutoCloseable
-
onStart
public void onStart(com.google.api.gax.rpc.StreamController streamController)
- Specified by:
onStart
in interfacecom.google.api.gax.rpc.ResponseObserver<StreamRequestT>
-
onResponse
public void onResponse(StreamResponseT response)
- Specified by:
onResponse
in interfacecom.google.api.gax.rpc.ResponseObserver<StreamRequestT>
-
onError
public void onError(Throwable t)
- Specified by:
onError
in interfacecom.google.api.gax.rpc.ResponseObserver<StreamRequestT>
-
onComplete
public void onComplete()
- Specified by:
onComplete
in interfacecom.google.api.gax.rpc.ResponseObserver<StreamRequestT>
-
-