public interface GrpcClientRequest<Req,Resp> extends GrpcWriteStream<Req>
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 service fullMethodName(java.lang.String)
.
Writing a request message will send the request to the service:
#end(Req)
#write(Req)
any time you need and then WriteStream.end()
Modifier and Type | Method and Description |
---|---|
HttpConnection |
connection() |
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.g
identity or gzip . |
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 format
package-name + '.' + service-name + '/' + method-name
or an IllegalArgumentException is thrown. |
GrpcClientRequest<Req,Resp> |
methodName(String methodName)
Set the method name to call.
|
Future<GrpcClientResponse<Req,Resp>> |
response() |
default Future<GrpcClientResponse<Req,Resp>> |
send(ReadStream<Req> body) |
default Future<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 to
maxSize . |
cancel, endMessage, headers, writeMessage
end, end, end, end, write, write, writeQueueFull
GrpcClientRequest<Req,Resp> encoding(String encoding)
GrpcWriteStream
identity
or gzip
.
It must be called before sending any message, otherwise {@code identity will be used.encoding
in interface GrpcWriteStream<Req>
encoding
- the target message encodingGrpcClientRequest<Req,Resp> fullMethodName(String fullMethodName)
package-name + '.' + service-name + '/' + method-name
or an IllegalArgumentException
is thrown.
It must be called before sending the request otherwise an IllegalStateException
is thrown.
fullMethodName
- the full method name to callGrpcClientRequest<Req,Resp> serviceName(ServiceName serviceName)
It must be called before sending the request otherwise an IllegalStateException
is thrown.
serviceName
- the service name to callGrpcClientRequest<Req,Resp> methodName(String methodName)
It must be called before sending the request otherwise an IllegalStateException
is thrown.
methodName
- the method name to callFuture<GrpcClientResponse<Req,Resp>> response()
GrpcClientRequest<Req,Resp> exceptionHandler(Handler<Throwable> handler)
WriteStream
exceptionHandler
in interface GrpcWriteStream<Req>
exceptionHandler
in interface StreamBase
exceptionHandler
in interface WriteStream<Req>
handler
- the exception handlerGrpcClientRequest<Req,Resp> setWriteQueueMaxSize(int maxSize)
WriteStream
maxSize
. 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
Pipe
to provide flow control.
The value is defined by the implementation of the stream, e.g in bytes for a
NetSocket
, etc...setWriteQueueMaxSize
in interface GrpcWriteStream<Req>
setWriteQueueMaxSize
in interface WriteStream<Req>
maxSize
- the max size of the write streamGrpcClientRequest<Req,Resp> drainHandler(Handler<Void> handler)
WriteStream
Pipe
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 GrpcWriteStream<Req>
drainHandler
in interface WriteStream<Req>
handler
- the handlerHttpConnection connection()
default Future<GrpcClientResponse<Req,Resp>> send(Req item)
default Future<GrpcClientResponse<Req,Resp>> send(ReadStream<Req> body)
Copyright © 2024 Eclipse. All rights reserved.