public class GrpcBidiExchangeImpl<I,O> extends Object implements GrpcBidiExchange<I,O>
| Constructor and Description |
|---|
GrpcBidiExchangeImpl(GrpcReadStream<I> readStream,
io.grpc.stub.StreamObserver<O> writeObserver) |
GrpcBidiExchangeImpl(io.grpc.stub.StreamObserver<I> readObserver,
io.grpc.stub.StreamObserver<O> writeObserver) |
| Modifier and Type | Method and Description |
|---|---|
GrpcBidiExchange<I,O> |
drainHandler(Handler<Void> handler)
Set a drain handler on the stream.
|
void |
end()
Ends the stream.
|
void |
end(Handler<AsyncResult<Void>> handler)
Same as
WriteStream.end() but with an handler called when the operation completes |
GrpcBidiExchange<I,O> |
endHandler(Handler<Void> handler)
Set an end handler.
|
GrpcBidiExchange<I,O> |
exceptionHandler(Handler<Throwable> handler)
Set an exception handler on the read stream.
|
GrpcBidiExchange<I,O> |
fail(Throwable t)
Send an error event into the stream.
|
GrpcBidiExchange<I,O> |
fetch(long amount)
Fetch the specified
amount of elements. |
GrpcBidiExchange<I,O> |
handler(Handler<I> handler)
Set a data handler.
|
GrpcBidiExchange<I,O> |
pause()
Pause the
ReadSupport. |
io.grpc.stub.StreamObserver<I> |
readObserver()
Should not be used by end user, it is a simple accessor the the underlying gRPC StreamObserver.
|
GrpcBidiExchange<I,O> |
resume()
Resume reading.
|
GrpcBidiExchange<I,O> |
setReadObserver(io.grpc.stub.StreamObserver<I> observer) |
GrpcBidiExchange<I,O> |
setWriteQueueMaxSize(int maxSize)
Set the maximum size of the write queue to
maxSize. |
GrpcBidiExchange<I,O> |
write(O data)
Write some data to the stream.
|
WriteStream<O> |
write(O data,
Handler<AsyncResult<Void>> handler)
Same as
#write(T) but with an handler called when the operation completes |
io.grpc.stub.StreamObserver<O> |
writeObserver()
Should not be used by end user, it is a simple accessor the the underlying gRPC StreamObserver.
|
boolean |
writeQueueFull()
This will return
true if there are more bytes in the write queue than the value set using WriteStream.setWriteQueueMaxSize(int) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcreate, createcreate, createpipe, pipeTo, pipeTocreateend, endpublic GrpcBidiExchangeImpl(GrpcReadStream<I> readStream, io.grpc.stub.StreamObserver<O> writeObserver)
public GrpcBidiExchange<I,O> exceptionHandler(Handler<Throwable> handler)
GrpcReadStreamexceptionHandler in interface ReadStream<I>exceptionHandler in interface StreamBaseexceptionHandler in interface WriteStream<O>exceptionHandler in interface GrpcBidiExchange<I,O>exceptionHandler in interface GrpcReadStream<I>exceptionHandler in interface GrpcWriteStream<O>handler - the exception handlerpublic GrpcBidiExchange<I,O> write(O data)
GrpcWriteStreamWriteStream.writeQueueFull() method before writing. This is done automatically if using a Pump.write in interface WriteStream<O>write in interface GrpcBidiExchange<I,O>write in interface GrpcWriteStream<O>data - the data to writepublic WriteStream<O> write(O data, Handler<AsyncResult<Void>> handler)
WriteStream#write(T) but with an handler called when the operation completeswrite in interface WriteStream<O>public void end()
WriteStreamOnce the stream has ended, it cannot be used any more.
end in interface WriteStream<O>public void end(Handler<AsyncResult<Void>> handler)
WriteStreamWriteStream.end() but with an handler called when the operation completesend in interface WriteStream<O>public GrpcBidiExchange<I,O> setWriteQueueMaxSize(int maxSize)
GrpcWriteStreammaxSize. You will still be able to write to the stream even
if there is more than maxSize items in the write queue. This is used as an indicator by classes such as
Pump to provide flow control.
The value is defined by the implementation of the stream, e.g in bytes for a
NetSocket, the number of Message for a
MessageProducer, etc...setWriteQueueMaxSize in interface WriteStream<O>setWriteQueueMaxSize in interface GrpcBidiExchange<I,O>setWriteQueueMaxSize in interface GrpcWriteStream<O>maxSize - the max size of the write streampublic boolean writeQueueFull()
WriteStreamtrue if there are more bytes in the write queue than the value set using WriteStream.setWriteQueueMaxSize(int)writeQueueFull in interface WriteStream<O>public GrpcBidiExchange<I,O> drainHandler(Handler<Void> handler)
GrpcWriteStreamPump for an example of this being used.
The stream implementation defines when the drain handler, for example it could be when the queue size has been
reduced to maxSize / 2.drainHandler in interface WriteStream<O>drainHandler in interface GrpcBidiExchange<I,O>drainHandler in interface GrpcWriteStream<O>handler - the handlerpublic GrpcBidiExchange<I,O> fail(Throwable t)
GrpcWriteStreamfail in interface GrpcBidiExchange<I,O>fail in interface GrpcWriteStream<O>t - any errorpublic GrpcBidiExchange<I,O> handler(Handler<I> handler)
GrpcReadStreamhandler in interface ReadStream<I>handler in interface GrpcBidiExchange<I,O>handler in interface GrpcReadStream<I>public GrpcBidiExchange<I,O> pause()
GrpcReadStreamReadSupport. While it's paused, no data will be sent to the dataHandlerpause in interface ReadStream<I>pause in interface GrpcBidiExchange<I,O>pause in interface GrpcReadStream<I>public GrpcBidiExchange<I,O> resume()
GrpcReadStreamReadSupport has been paused, reading will recommence on it.resume in interface ReadStream<I>resume in interface GrpcBidiExchange<I,O>resume in interface GrpcReadStream<I>public GrpcBidiExchange<I,O> fetch(long amount)
GrpcReadStreamamount of elements. If the ReadStream has been paused, reading will
recommence with the specified amount of items, otherwise the specified amount will
be added to the current stream demand.fetch in interface ReadStream<I>fetch in interface GrpcBidiExchange<I,O>fetch in interface GrpcReadStream<I>public GrpcBidiExchange<I,O> endHandler(Handler<Void> handler)
GrpcReadStreamendHandler in interface ReadStream<I>endHandler in interface GrpcBidiExchange<I,O>endHandler in interface GrpcReadStream<I>public io.grpc.stub.StreamObserver<I> readObserver()
GrpcReadStreamreadObserver in interface GrpcBidiExchange<I,O>readObserver in interface GrpcReadStream<I>public GrpcBidiExchange<I,O> setReadObserver(io.grpc.stub.StreamObserver<I> observer)
setReadObserver in interface GrpcBidiExchange<I,O>setReadObserver in interface GrpcReadStream<I>public io.grpc.stub.StreamObserver<O> writeObserver()
GrpcWriteStreamwriteObserver in interface GrpcBidiExchange<I,O>writeObserver in interface GrpcWriteStream<O>Copyright © 2020. All rights reserved.