public class GrpcWriteStreamImpl<T> extends Object implements GrpcWriteStream<T>
| Constructor and Description |
|---|
GrpcWriteStreamImpl(io.grpc.stub.StreamObserver<T> observer) |
| Modifier and Type | Method and Description |
|---|---|
GrpcWriteStreamImpl<T> |
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 |
GrpcWriteStreamImpl<T> |
exceptionHandler(Handler<Throwable> handler)
Set an exception handler on the write stream.
|
GrpcWriteStreamImpl<T> |
fail(Throwable t)
Send an error event into the stream.
|
GrpcWriteStreamImpl<T> |
setWriteQueueMaxSize(int i)
Set the maximum size of the write queue to
maxSize. |
GrpcWriteStreamImpl<T> |
write(T t)
Write some data to the stream.
|
WriteStream<T> |
write(T data,
Handler<AsyncResult<Void>> handler)
Same as
#write(T) but with an handler called when the operation completes |
io.grpc.stub.StreamObserver<T> |
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, waitcreateend, endpublic GrpcWriteStreamImpl(io.grpc.stub.StreamObserver<T> observer)
public GrpcWriteStreamImpl<T> exceptionHandler(Handler<Throwable> handler)
GrpcWriteStreamexceptionHandler in interface StreamBaseexceptionHandler in interface WriteStream<T>exceptionHandler in interface GrpcWriteStream<T>handler - the exception handlerpublic WriteStream<T> write(T data, Handler<AsyncResult<Void>> handler)
WriteStream#write(T) but with an handler called when the operation completeswrite in interface WriteStream<T>public GrpcWriteStreamImpl<T> write(T t)
GrpcWriteStreamWriteStream.writeQueueFull() method before writing. This is done automatically if using a Pump.write in interface WriteStream<T>write in interface GrpcWriteStream<T>t - the data to writepublic void end()
WriteStreamOnce the stream has ended, it cannot be used any more.
end in interface WriteStream<T>public void end(Handler<AsyncResult<Void>> handler)
WriteStreamWriteStream.end() but with an handler called when the operation completesend in interface WriteStream<T>public GrpcWriteStreamImpl<T> setWriteQueueMaxSize(int i)
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<T>setWriteQueueMaxSize in interface GrpcWriteStream<T>i - 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<T>public GrpcWriteStreamImpl<T> 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<T>drainHandler in interface GrpcWriteStream<T>handler - the handlerpublic GrpcWriteStreamImpl<T> fail(Throwable t)
GrpcWriteStreamfail in interface GrpcWriteStream<T>t - any errorpublic io.grpc.stub.StreamObserver<T> writeObserver()
GrpcWriteStreamwriteObserver in interface GrpcWriteStream<T>Copyright © 2020. All rights reserved.