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_ARG
TypeArg<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 void
cancel()
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.gidentity
orgzip
.void
end()
Same asWriteStream.end(io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)
but with anhandler
called when the operation completesvoid
end(Handler<AsyncResult<Void>> handler)
Same asWriteStream.end(io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)
but with anhandler
called when the operation completesvoid
end(T data)
Same as but with anhandler
called when the operation completesvoid
end(T data, Handler<AsyncResult<Void>> handler)
Same as but with anhandler
called when the operation completesFuture<Void>
endMessage(GrpcMessage message)
End the stream with an encoded gRPC message.boolean
equals(Object o)
GrpcWriteStream<T>
exceptionHandler(Handler<Throwable> handler)
Set an exception handler on the write stream.GrpcWriteStream
getDelegate()
int
hashCode()
MultiMap
headers()
static <T> GrpcWriteStream<T>
newInstance(GrpcWriteStream arg)
static <T> GrpcWriteStream<T>
newInstance(GrpcWriteStream arg, TypeArg<T> __typeArg_T)
io.reactivex.Completable
rxEnd()
Same asWriteStream.end(io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)
but with anhandler
called when the operation completesio.reactivex.Completable
rxEnd(T data)
Same as but with anhandler
called when the operation completesio.reactivex.Completable
rxEndMessage(GrpcMessage message)
End the stream with an encoded gRPC message.io.reactivex.Completable
rxWrite(T data)
Same as but with anhandler
called when the operation completesio.reactivex.Completable
rxWriteMessage(GrpcMessage message)
Write an encoded gRPC message.GrpcWriteStream<T>
setWriteQueueMaxSize(int i)
Set the maximum size of the write queue tomaxSize
.WriteStreamObserver<T>
toObserver()
String
toString()
WriteStreamSubscriber<T>
toSubscriber()
void
write(T data)
Same as but with anhandler
called when the operation completesvoid
write(T data, Handler<AsyncResult<Void>> handler)
Same as but with anhandler
called when the operation completesFuture<Void>
writeMessage(GrpcMessage message)
Write an encoded gRPC message.boolean
writeQueueFull()
This will returntrue
if 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:
getDelegate
in interfaceStreamBase
- Specified by:
getDelegate
in 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 anhandler
called when the operation completes- Specified by:
write
in interfaceWriteStream<T>
- Parameters:
data
-handler
-
-
write
public void write(T data)
Same as but with anhandler
called when the operation completes- Specified by:
write
in interfaceWriteStream<T>
- Parameters:
data
-
-
rxWrite
public io.reactivex.Completable rxWrite(T data)
Same as but with anhandler
called when the operation completes- Specified by:
rxWrite
in 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 anhandler
called when the operation completes- Specified by:
end
in interfaceWriteStream<T>
- Parameters:
handler
-
-
end
public void end()
Same asWriteStream.end(io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)
but with anhandler
called when the operation completes- Specified by:
end
in interfaceWriteStream<T>
-
rxEnd
public io.reactivex.Completable rxEnd()
Same asWriteStream.end(io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)
but with anhandler
called when the operation completes- Specified by:
rxEnd
in interfaceWriteStream<T>
- Returns:
-
end
public void end(T data, Handler<AsyncResult<Void>> handler)
Same as but with anhandler
called when the operation completes- Specified by:
end
in interfaceWriteStream<T>
- Parameters:
data
-handler
-
-
end
public void end(T data)
Same as but with anhandler
called when the operation completes- Specified by:
end
in interfaceWriteStream<T>
- Parameters:
data
-
-
rxEnd
public io.reactivex.Completable rxEnd(T data)
Same as but with anhandler
called when the operation completes- Specified by:
rxEnd
in interfaceWriteStream<T>
- Parameters:
data
-- Returns:
-
writeQueueFull
public boolean writeQueueFull()
This will returntrue
if there are more bytes in the write queue than the value set usingsetWriteQueueMaxSize(int)
- Specified by:
writeQueueFull
in interfaceWriteStream<T>
- Returns:
true
if 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.gidentity
orgzip
. 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:WriteStream
Set an exception handler on the write stream.- Specified by:
exceptionHandler
in interfaceStreamBase
- Specified by:
exceptionHandler
in 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:WriteStream
Set the maximum size of the write queue tomaxSize
. You will still be able to write to the stream even if there is more thanmaxSize
items in the write queue. This is used as an indicator by classes such asPipe
to provide flow control. The value is defined by the implementation of the stream, e.g in bytes for aNetSocket
, etc...- Specified by:
setWriteQueueMaxSize
in 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:WriteStream
Set 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. SeePipe
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
.- Specified by:
drainHandler
in 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)
-
-