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

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

Name Description
StreamRequestT
StreamResponseT
ClientResponseT

Static Fields

DEFAULT_STREAM_IDLE_TIMEOUT

protected static final Duration DEFAULT_STREAM_IDLE_TIMEOUT
Field Value
Type Description
Duration

Constructors

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

protected SingleConnection(StreamFactory<StreamRequestT,StreamResponseT> streamFactory, ResponseObserver<ClientResponseT> clientStream)
Parameters
Name Description
streamFactory StreamFactory<StreamRequestT,StreamResponseT>
clientStream ResponseObserver<ClientResponseT>

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

protected SingleConnection(StreamFactory<StreamRequestT,StreamResponseT> streamFactory, ResponseObserver<ClientResponseT> clientStream, Duration streamIdleTimeout)
Parameters
Name Description
streamFactory StreamFactory<StreamRequestT,StreamResponseT>
clientStream ResponseObserver<ClientResponseT>
streamIdleTimeout Duration

Methods

close()

public void close()

handleStreamResponse(StreamResponseT response)

protected abstract void handleStreamResponse(StreamResponseT response)
Parameter
Name Description
response StreamResponseT
Exceptions
Type Description
CheckedApiException

initialize(StreamRequestT initialRequest)

protected void initialize(StreamRequestT initialRequest)
Parameter
Name Description
initialRequest StreamRequestT

onComplete()

public void onComplete()

onError(Throwable t)

public void onError(Throwable t)
Parameter
Name Description
t Throwable

onResponse(StreamResponseT response)

public void onResponse(StreamResponseT response)
Parameter
Name Description
response StreamResponseT

onStart(StreamController streamController)

public void onStart(StreamController streamController)
Parameter
Name Description
streamController StreamController

sendToClient(ClientResponseT response)

protected void sendToClient(ClientResponseT response)
Parameter
Name Description
response ClientResponseT

sendToStream(StreamRequestT request)

protected synchronized void sendToStream(StreamRequestT request)
Parameter
Name Description
request StreamRequestT

setError(CheckedApiException error)

protected void setError(CheckedApiException error)
Parameter
Name Description
error CheckedApiException