Class FlowControlledStream<IN,OUT>
- java.lang.Object
-
- io.axoniq.axonserver.connector.impl.FlowControlledStream<IN,OUT>
-
- Type Parameters:
IN- the type of entries returned by this streamOUT- the type of message used for flow control in this stream
- All Implemented Interfaces:
io.grpc.stub.ClientResponseObserver<OUT,IN>,io.grpc.stub.StreamObserver<IN>
- Direct Known Subclasses:
AbstractIncomingInstructionStream,FlowControlledBuffer,SubscriptionQueryStream
public abstract class FlowControlledStream<IN,OUT> extends Object implements io.grpc.stub.ClientResponseObserver<OUT,IN>
Abstract implementation of aClientResponseObserverproviding flow control.
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedFlowControlledStream(String clientId, int permits, int refillBatch)Constructs aFlowControlledStream.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidbeforeStart(io.grpc.stub.ClientCallStreamObserver<OUT> requestStream)protected abstract OUTbuildFlowControlMessage(FlowControl flowControl)Build a flow control message of typeOUTbased on the givenflowControl.protected OUTbuildInitialFlowControlMessage(FlowControl flowControl)Builds the initial flow control message of typeOUTbased on the givenflowControl.voidenableFlowControl()Enables flow control for this stream.protected voidmarkConsumed()Notifier when an entry has been consumed from this stream.protected io.grpc.stub.ClientCallStreamObserver<OUT>outboundStream()Return theClientCallStreamObserverserving as the outbound stream.
-
-
-
Constructor Detail
-
FlowControlledStream
protected FlowControlledStream(String clientId, int permits, int refillBatch)
Constructs aFlowControlledStream.- Parameters:
clientId- the client identifier which initiated this streampermits- the number of permits this stream should receiverefillBatch- the number of permits to be consumed prior to requesting new permits
-
-
Method Detail
-
enableFlowControl
public void enableFlowControl()
Enables flow control for this stream. Will only set up flow control if the permits batch size is larger than0.
-
buildFlowControlMessage
protected abstract OUT buildFlowControlMessage(FlowControl flowControl)
Build a flow control message of typeOUTbased on the givenflowControl.- Parameters:
flowControl- theFlowControlmessage used to base this implementation's flow control message on- Returns:
- the message used by this implementation to request new entries of type
IN
-
buildInitialFlowControlMessage
protected OUT buildInitialFlowControlMessage(FlowControl flowControl)
Builds the initial flow control message of typeOUTbased on the givenflowControl.- Parameters:
flowControl- theFlowControlmessage used to base this implementation's flow control message on- Returns:
- the initial message used by this implementation to request new entries of type
IN
-
markConsumed
protected void markConsumed()
Notifier when an entry has been consumed from this stream. Keeps track of the number of permits which has been consumed and will automatically ask for new permits if thepermitsBatchsize has been reached.
-
beforeStart
public void beforeStart(io.grpc.stub.ClientCallStreamObserver<OUT> requestStream)
-
outboundStream
protected io.grpc.stub.ClientCallStreamObserver<OUT> outboundStream()
Return theClientCallStreamObserverserving as the outbound stream. Can be used to send additional messages required to tap into the flow control of this stream, or the complete the stream altogether.- Returns:
- the
ClientCallStreamObserverserving as the outbound stream
-
-