Package io.vertx.reactivex.grpc.common
Class GrpcWriteStream<T>
- java.lang.Object
-
- io.vertx.reactivex.grpc.common.GrpcWriteStream<T>
-
- All Implemented Interfaces:
StreamBase,WriteStream<T>
- Direct Known Subclasses:
GrpcClientRequest,GrpcServerResponse
public class GrpcWriteStream<T> extends Object implements WriteStream<T>
-
-
Field Summary
Fields Modifier and Type Field Description static TypeArg<GrpcWriteStream>__TYPE_ARGTypeArg<T>__typeArg_0
-
Constructor Summary
Constructors Constructor Description GrpcWriteStream(GrpcWriteStream delegate)GrpcWriteStream(Object delegate, TypeArg<T> typeArg_0)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcancel()Cancel the stream.GrpcWriteStream<T>drainHandler(Handler<Void> handler)Set a drain handler on the stream.GrpcWriteStream<T>encoding(String encoding)Set the stream encoding, e.gidentityorgzip.voidend()Same asWriteStream.end(io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)but with anhandlercalled when the operation completesvoidend(Handler<AsyncResult<Void>> handler)Same asWriteStream.end(io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)but with anhandlercalled when the operation completesvoidend(T data)Same as but with anhandlercalled when the operation completesvoidend(T data, Handler<AsyncResult<Void>> handler)Same as but with anhandlercalled when the operation completesFuture<Void>endMessage(GrpcMessage message)End the stream with an encoded gRPC message.booleanequals(Object o)GrpcWriteStream<T>exceptionHandler(Handler<Throwable> handler)Set an exception handler on the write stream.GrpcWriteStreamgetDelegate()inthashCode()MultiMapheaders()static <T> GrpcWriteStream<T>newInstance(GrpcWriteStream arg)static <T> GrpcWriteStream<T>newInstance(GrpcWriteStream arg, TypeArg<T> __typeArg_T)io.reactivex.CompletablerxEnd()Same asWriteStream.end(io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)but with anhandlercalled when the operation completesio.reactivex.CompletablerxEnd(T data)Same as but with anhandlercalled when the operation completesio.reactivex.CompletablerxEndMessage(GrpcMessage message)End the stream with an encoded gRPC message.io.reactivex.CompletablerxWrite(T data)Same as but with anhandlercalled when the operation completesio.reactivex.CompletablerxWriteMessage(GrpcMessage message)Write an encoded gRPC message.GrpcWriteStream<T>setWriteQueueMaxSize(int i)Set the maximum size of the write queue tomaxSize.WriteStreamObserver<T>toObserver()StringtoString()WriteStreamSubscriber<T>toSubscriber()voidwrite(T data)Same as but with anhandlercalled when the operation completesvoidwrite(T data, Handler<AsyncResult<Void>> handler)Same as but with anhandlercalled when the operation completesFuture<Void>writeMessage(GrpcMessage message)Write an encoded gRPC message.booleanwriteQueueFull()This will returntrueif there are more bytes in the write queue than the value set usingsetWriteQueueMaxSize(int)
-
-
-
Field Detail
-
__TYPE_ARG
public static final TypeArg<GrpcWriteStream> __TYPE_ARG
-
-
Constructor Detail
-
GrpcWriteStream
public GrpcWriteStream(GrpcWriteStream delegate)
-
-
Method Detail
-
getDelegate
public GrpcWriteStream getDelegate()
- Specified by:
getDelegatein interfaceStreamBase- Specified by:
getDelegatein interfaceWriteStream<T>
-
toObserver
public WriteStreamObserver<T> toObserver()
-
toSubscriber
public WriteStreamSubscriber<T> toSubscriber()
-
write
public void write(T data, Handler<AsyncResult<Void>> handler)
Same as but with anhandlercalled when the operation completes- Specified by:
writein interfaceWriteStream<T>- Parameters:
data-handler-
-
write
public void write(T data)
Same as but with anhandlercalled when the operation completes- Specified by:
writein interfaceWriteStream<T>- Parameters:
data-
-
rxWrite
public io.reactivex.Completable rxWrite(T data)
Same as but with anhandlercalled when the operation completes- Specified by:
rxWritein interfaceWriteStream<T>- Parameters:
data-- Returns:
-
end
public void end(Handler<AsyncResult<Void>> handler)
Same asWriteStream.end(io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)but with anhandlercalled when the operation completes- Specified by:
endin interfaceWriteStream<T>- Parameters:
handler-
-
end
public void end()
Same asWriteStream.end(io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)but with anhandlercalled when the operation completes- Specified by:
endin interfaceWriteStream<T>
-
rxEnd
public io.reactivex.Completable rxEnd()
Same asWriteStream.end(io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)but with anhandlercalled when the operation completes- Specified by:
rxEndin interfaceWriteStream<T>- Returns:
-
end
public void end(T data, Handler<AsyncResult<Void>> handler)
Same as but with anhandlercalled when the operation completes- Specified by:
endin interfaceWriteStream<T>- Parameters:
data-handler-
-
end
public void end(T data)
Same as but with anhandlercalled when the operation completes- Specified by:
endin interfaceWriteStream<T>- Parameters:
data-
-
rxEnd
public io.reactivex.Completable rxEnd(T data)
Same as but with anhandlercalled when the operation completes- Specified by:
rxEndin interfaceWriteStream<T>- Parameters:
data-- Returns:
-
writeQueueFull
public boolean writeQueueFull()
This will returntrueif there are more bytes in the write queue than the value set usingsetWriteQueueMaxSize(int)- Specified by:
writeQueueFullin interfaceWriteStream<T>- Returns:
trueif write queue is full
-
headers
public MultiMap headers()
- Returns:
- the to reader metadata headers
-
encoding
public GrpcWriteStream<T> encoding(String encoding)
Set the stream encoding, e.gidentityorgzip. It must be called before sending any message, otherwise {@code identity will be used.- Parameters:
encoding- the target message encoding- Returns:
- a reference to this, so the API can be used fluently
-
exceptionHandler
public GrpcWriteStream<T> exceptionHandler(Handler<Throwable> handler)
Description copied from interface:WriteStreamSet an exception handler on the write stream.- Specified by:
exceptionHandlerin interfaceStreamBase- Specified by:
exceptionHandlerin interfaceWriteStream<T>- Parameters:
handler- the exception handler- Returns:
- a reference to this, so the API can be used fluently
-
setWriteQueueMaxSize
public GrpcWriteStream<T> setWriteQueueMaxSize(int i)
Description copied from interface:WriteStreamSet the maximum size of the write queue tomaxSize. You will still be able to write to the stream even if there is more thanmaxSizeitems in the write queue. This is used as an indicator by classes such asPipeto provide flow control. The value is defined by the implementation of the stream, e.g in bytes for aNetSocket, etc...- Specified by:
setWriteQueueMaxSizein interfaceWriteStream<T>- Parameters:
i- the max size of the write stream- Returns:
- a reference to this, so the API can be used fluently
-
drainHandler
public GrpcWriteStream<T> drainHandler(Handler<Void> handler)
Description copied from interface:WriteStreamSet a drain handler on the stream. If the write queue is full, then the handler will be called when the write queue is ready to accept buffers again. SeePipefor 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.- Specified by:
drainHandlerin interfaceWriteStream<T>- Parameters:
handler- the handler- Returns:
- a reference to this, so the API can be used fluently
-
writeMessage
public Future<Void> writeMessage(GrpcMessage message)
Write an encoded gRPC message.- Parameters:
message- the message- Returns:
- a future completed with the result
-
rxWriteMessage
public io.reactivex.Completable rxWriteMessage(GrpcMessage message)
Write an encoded gRPC message.- Parameters:
message- the message- Returns:
- a future completed with the result
-
endMessage
public Future<Void> endMessage(GrpcMessage message)
End the stream with an encoded gRPC message.- Parameters:
message- the message- Returns:
- a future completed with the result
-
rxEndMessage
public io.reactivex.Completable rxEndMessage(GrpcMessage message)
End the stream with an encoded gRPC message.- Parameters:
message- the message- Returns:
- a future completed with the result
-
cancel
public void cancel()
Cancel the stream.
-
newInstance
public static <T> GrpcWriteStream<T> newInstance(GrpcWriteStream arg)
-
newInstance
public static <T> GrpcWriteStream<T> newInstance(GrpcWriteStream arg, TypeArg<T> __typeArg_T)
-
-