Package io.vertx.rxjava3.grpc.client
Class GrpcClientRequest<Req,Resp>
- java.lang.Object
-
- io.vertx.rxjava3.grpc.common.GrpcWriteStream<Req>
-
- io.vertx.rxjava3.grpc.client.GrpcClientRequest<Req,Resp>
-
- All Implemented Interfaces:
StreamBase,WriteStream<Req>
public class GrpcClientRequest<Req,Resp> extends GrpcWriteStream<Req>
A request to a gRPC server.You interact with the remote service with gRPC generated messages or protobuf encoded messages.
Before sending a request you need to set
#serviceName)and#methodName)or alternatively the servicefullMethodName(java.lang.String).Writing a request message will send the request to the service:
- To send a unary request, just call
- To send a streaming request, call any time you need and then
WriteStream.end()
originalnon RX-ified interface using Vert.x codegen.
-
-
Field Summary
Fields Modifier and Type Field Description static TypeArg<GrpcClientRequest>__TYPE_ARGTypeArg<Req>__typeArg_0TypeArg<Resp>__typeArg_1
-
Constructor Summary
Constructors Constructor Description GrpcClientRequest(GrpcClientRequest delegate)GrpcClientRequest(Object delegate, TypeArg<Req> typeArg_0, TypeArg<Resp> typeArg_1)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description HttpConnectionconnection()GrpcClientRequest<Req,Resp>drainHandler(Handler<Void> handler)Set a drain handler on the stream.GrpcClientRequest<Req,Resp>encoding(String encoding)Set the stream encoding, e.gidentityorgzip.io.reactivex.rxjava3.core.Completableend()Same asWriteStream.end()but with anhandlercalled when the operation completesio.reactivex.rxjava3.core.Completableend(Req data)Same as but with anhandlercalled when the operation completesbooleanequals(Object o)GrpcClientRequest<Req,Resp>exceptionHandler(Handler<Throwable> handler)Set an exception handler on the write stream.GrpcClientRequest<Req,Resp>fullMethodName(String fullMethodName)Set the full method name to call, it must follow the formatpackage-name + '.' + service-name + '/' + method-nameor anIllegalArgumentExceptionis thrown.GrpcClientRequestgetDelegate()inthashCode()GrpcClientRequest<Req,Resp>methodName(String methodName)Set the method name to call.static <Req,Resp>
GrpcClientRequest<Req,Resp>newInstance(GrpcClientRequest arg)static <Req,Resp>
GrpcClientRequest<Req,Resp>newInstance(GrpcClientRequest arg, TypeArg<Req> __typeArg_Req, TypeArg<Resp> __typeArg_Resp)io.reactivex.rxjava3.core.Single<GrpcClientResponse<Req,Resp>>response()io.reactivex.rxjava3.core.CompletablerxEnd()Same asWriteStream.end()but with anhandlercalled when the operation completesio.reactivex.rxjava3.core.CompletablerxEnd(Req data)Same as but with anhandlercalled when the operation completesio.reactivex.rxjava3.core.Single<GrpcClientResponse<Req,Resp>>rxResponse()io.reactivex.rxjava3.core.Single<GrpcClientResponse<Req,Resp>>rxSend(io.reactivex.rxjava3.core.Flowable<Req> body)io.reactivex.rxjava3.core.Single<GrpcClientResponse<Req,Resp>>rxSend(Req item)io.reactivex.rxjava3.core.CompletablerxWrite(Req data)Same as but with anhandlercalled when the operation completesio.reactivex.rxjava3.core.Single<GrpcClientResponse<Req,Resp>>send(io.reactivex.rxjava3.core.Flowable<Req> body)io.reactivex.rxjava3.core.Single<GrpcClientResponse<Req,Resp>>send(Req item)GrpcClientRequest<Req,Resp>serviceName(ServiceName serviceName)Set the service name to call.GrpcClientRequest<Req,Resp>setWriteQueueMaxSize(int maxSize)Set the maximum size of the write queue tomaxSize.WriteStreamObserver<Req>toObserver()StringtoString()WriteStreamSubscriber<Req>toSubscriber()io.reactivex.rxjava3.core.Completablewrite(Req data)Same as but with anhandlercalled when the operation completesbooleanwriteQueueFull()This will returntrueif there are more bytes in the write queue than the value set usingsetWriteQueueMaxSize(int)-
Methods inherited from class io.vertx.rxjava3.grpc.common.GrpcWriteStream
cancel, endMessage, headers, newInstance, newInstance, rxEndMessage, rxWriteMessage, writeMessage
-
-
-
-
Method Detail
-
toString
public String toString()
- Overrides:
toStringin classGrpcWriteStream<Req>
-
equals
public boolean equals(Object o)
- Overrides:
equalsin classGrpcWriteStream<Req>
-
hashCode
public int hashCode()
- Overrides:
hashCodein classGrpcWriteStream<Req>
-
getDelegate
public GrpcClientRequest getDelegate()
- Specified by:
getDelegatein interfaceStreamBase- Specified by:
getDelegatein interfaceWriteStream<Req>- Overrides:
getDelegatein classGrpcWriteStream<Req>
-
toObserver
public WriteStreamObserver<Req> toObserver()
- Overrides:
toObserverin classGrpcWriteStream<Req>
-
toSubscriber
public WriteStreamSubscriber<Req> toSubscriber()
- Overrides:
toSubscriberin classGrpcWriteStream<Req>
-
write
public io.reactivex.rxjava3.core.Completable write(Req data)
Same as but with anhandlercalled when the operation completes- Specified by:
writein interfaceWriteStream<Req>- Overrides:
writein classGrpcWriteStream<Req>- Parameters:
data-- Returns:
-
rxWrite
public io.reactivex.rxjava3.core.Completable rxWrite(Req data)
Same as but with anhandlercalled when the operation completes- Specified by:
rxWritein interfaceWriteStream<Req>- Overrides:
rxWritein classGrpcWriteStream<Req>- Parameters:
data-- Returns:
-
end
public io.reactivex.rxjava3.core.Completable end()
Same asWriteStream.end()but with anhandlercalled when the operation completes- Specified by:
endin interfaceWriteStream<Req>- Overrides:
endin classGrpcWriteStream<Req>- Returns:
-
rxEnd
public io.reactivex.rxjava3.core.Completable rxEnd()
Same asWriteStream.end()but with anhandlercalled when the operation completes- Specified by:
rxEndin interfaceWriteStream<Req>- Overrides:
rxEndin classGrpcWriteStream<Req>- Returns:
-
end
public io.reactivex.rxjava3.core.Completable end(Req data)
Same as but with anhandlercalled when the operation completes- Specified by:
endin interfaceWriteStream<Req>- Overrides:
endin classGrpcWriteStream<Req>- Parameters:
data-- Returns:
-
rxEnd
public io.reactivex.rxjava3.core.Completable rxEnd(Req data)
Same as but with anhandlercalled when the operation completes- Specified by:
rxEndin interfaceWriteStream<Req>- Overrides:
rxEndin classGrpcWriteStream<Req>- 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<Req>- Overrides:
writeQueueFullin classGrpcWriteStream<Req>- Returns:
trueif write queue is full
-
encoding
public GrpcClientRequest<Req,Resp> encoding(String encoding)
Description copied from class:GrpcWriteStreamSet the stream encoding, e.gidentityorgzip. It must be called before sending any message, otherwise {@code identity will be used.- Overrides:
encodingin classGrpcWriteStream<Req>- Parameters:
encoding- the target message encoding- Returns:
- a reference to this, so the API can be used fluently
-
fullMethodName
public GrpcClientRequest<Req,Resp> fullMethodName(String fullMethodName)
Set the full method name to call, it must follow the formatpackage-name + '.' + service-name + '/' + method-nameor anIllegalArgumentExceptionis thrown.It must be called before sending the request otherwise an
IllegalStateExceptionis thrown.- Parameters:
fullMethodName- the full method name to call- Returns:
- a reference to this, so the API can be used fluently
-
serviceName
public GrpcClientRequest<Req,Resp> serviceName(ServiceName serviceName)
Set the service name to call.It must be called before sending the request otherwise an
IllegalStateExceptionis thrown.- Parameters:
serviceName- the service name to call- Returns:
- a reference to this, so the API can be used fluently
-
methodName
public GrpcClientRequest<Req,Resp> methodName(String methodName)
Set the method name to call.It must be called before sending the request otherwise an
IllegalStateExceptionis thrown.- Parameters:
methodName- the method name to call- Returns:
- a reference to this, so the API can be used fluently
-
response
public io.reactivex.rxjava3.core.Single<GrpcClientResponse<Req,Resp>> response()
- Returns:
- the gRPC response
-
rxResponse
public io.reactivex.rxjava3.core.Single<GrpcClientResponse<Req,Resp>> rxResponse()
- Returns:
- the gRPC response
-
exceptionHandler
public GrpcClientRequest<Req,Resp> exceptionHandler(Handler<Throwable> handler)
Description copied from interface:WriteStreamSet an exception handler on the write stream.- Specified by:
exceptionHandlerin interfaceStreamBase- Specified by:
exceptionHandlerin interfaceWriteStream<Req>- Overrides:
exceptionHandlerin classGrpcWriteStream<Req>- Parameters:
handler- the exception handler- Returns:
- a reference to this, so the API can be used fluently
-
setWriteQueueMaxSize
public GrpcClientRequest<Req,Resp> setWriteQueueMaxSize(int maxSize)
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<Req>- Overrides:
setWriteQueueMaxSizein classGrpcWriteStream<Req>- Parameters:
maxSize- the max size of the write stream- Returns:
- a reference to this, so the API can be used fluently
-
drainHandler
public GrpcClientRequest<Req,Resp> 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<Req>- Overrides:
drainHandlerin classGrpcWriteStream<Req>- Parameters:
handler- the handler- Returns:
- a reference to this, so the API can be used fluently
-
connection
public HttpConnection connection()
- Returns:
- the underlying HTTP connection
-
send
public io.reactivex.rxjava3.core.Single<GrpcClientResponse<Req,Resp>> send(Req item)
-
rxSend
public io.reactivex.rxjava3.core.Single<GrpcClientResponse<Req,Resp>> rxSend(Req item)
-
send
public io.reactivex.rxjava3.core.Single<GrpcClientResponse<Req,Resp>> send(io.reactivex.rxjava3.core.Flowable<Req> body)
-
rxSend
public io.reactivex.rxjava3.core.Single<GrpcClientResponse<Req,Resp>> rxSend(io.reactivex.rxjava3.core.Flowable<Req> body)
-
newInstance
public static <Req,Resp> GrpcClientRequest<Req,Resp> newInstance(GrpcClientRequest arg)
-
newInstance
public static <Req,Resp> GrpcClientRequest<Req,Resp> newInstance(GrpcClientRequest arg, TypeArg<Req> __typeArg_Req, TypeArg<Resp> __typeArg_Resp)
-
-