Class SingleConnection<StreamRequestT,StreamResponseT,ClientResponseT> (1.6.3)

public abstract class SingleConnection<StreamRequestT,StreamResponseT,ClientResponseT> implements 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.

Inheritance

java.lang.Object > SingleConnection<StreamRequestT,StreamResponseT,ClientResponseT>

Implements

com.google.api.gax.rpc.ResponseObserver<StreamResponseT>, AutoCloseable

Type Parameters

NameDescription
StreamRequestT
StreamResponseT
ClientResponseT

Static Fields

DEFAULT_STREAM_IDLE_TIMEOUT

protected static final Duration DEFAULT_STREAM_IDLE_TIMEOUT
Field Value
TypeDescription
Duration

Constructors

SingleConnection(StreamFactory<StreamRequestT,StreamResponseT> streamFactory, ResponseObserver<ClientResponseT> clientStream)

protected SingleConnection(StreamFactory<StreamRequestT,StreamResponseT> streamFactory, ResponseObserver<ClientResponseT> clientStream)
Parameters
NameDescription
streamFactoryStreamFactory<StreamRequestT,StreamResponseT>
clientStreamResponseObserver<ClientResponseT>

SingleConnection(StreamFactory<StreamRequestT,StreamResponseT> streamFactory, ResponseObserver<ClientResponseT> clientStream, Duration streamIdleTimeout, boolean expectInitialResponse)

protected SingleConnection(StreamFactory<StreamRequestT,StreamResponseT> streamFactory, ResponseObserver<ClientResponseT> clientStream, Duration streamIdleTimeout, boolean expectInitialResponse)
Parameters
NameDescription
streamFactoryStreamFactory<StreamRequestT,StreamResponseT>
clientStreamResponseObserver<ClientResponseT>
streamIdleTimeoutDuration
expectInitialResponseboolean

Methods

close()

public void close()

handleInitialResponse(StreamResponseT response)

protected abstract void handleInitialResponse(StreamResponseT response)
Parameter
NameDescription
responseStreamResponseT
Exceptions
TypeDescription
CheckedApiException

handleStreamResponse(StreamResponseT response)

protected abstract void handleStreamResponse(StreamResponseT response)
Parameter
NameDescription
responseStreamResponseT
Exceptions
TypeDescription
CheckedApiException

initialize(StreamRequestT initialRequest)

protected void initialize(StreamRequestT initialRequest)
Parameter
NameDescription
initialRequestStreamRequestT

isCompleted()

protected boolean isCompleted()
Returns
TypeDescription
boolean

onComplete()

public void onComplete()

onError(Throwable t)

public void onError(Throwable t)
Parameter
NameDescription
tThrowable

onResponse(StreamResponseT response)

public void onResponse(StreamResponseT response)
Parameter
NameDescription
responseStreamResponseT

onStart(StreamController streamController)

public void onStart(StreamController streamController)
Parameter
NameDescription
streamControllerStreamController

sendToClient(ClientResponseT response)

protected void sendToClient(ClientResponseT response)
Parameter
NameDescription
responseClientResponseT

sendToStream(StreamRequestT request)

protected void sendToStream(StreamRequestT request)
Parameter
NameDescription
requestStreamRequestT

setError(CheckedApiException error)

protected void setError(CheckedApiException error)
Parameter
NameDescription
errorCheckedApiException