ReqT
- type of the requestResT
- type of the response@NotThreadSafe public class GrpcBlockingStream<ReqT,ResT> extends Object
Constructor and Description |
---|
GrpcBlockingStream(java.util.function.Function<io.grpc.stub.StreamObserver<ResT>,io.grpc.stub.StreamObserver<ReqT>> rpcFunc,
int bufferSize,
String description) |
Modifier and Type | Method and Description |
---|---|
void |
cancel()
Cancels the stream.
|
void |
close()
Closes the outbound stream.
|
boolean |
isCanceled() |
boolean |
isClosed() |
boolean |
isOpen() |
ResT |
receive(long timeoutMs)
Receives a response from the server.
|
void |
send(ReqT request)
Sends a request.
|
void |
send(ReqT request,
long timeoutMs)
Sends a request.
|
Optional<ResT> |
waitForComplete(long timeoutMs)
Wait for server to complete the inbound stream.
|
public GrpcBlockingStream(java.util.function.Function<io.grpc.stub.StreamObserver<ResT>,io.grpc.stub.StreamObserver<ReqT>> rpcFunc, int bufferSize, String description)
rpcFunc
- the gRPC bi-directional stream stub functionbufferSize
- maximum number of incoming messages the buffer can holddescription
- description of this streampublic void send(ReqT request, long timeoutMs) throws IOException
request
- the requesttimeoutMs
- maximum wait time before throwing a DeadlineExceededException
IOException
- if any error occurspublic void send(ReqT request) throws IOException
request
- the requestIOException
- if any error occurspublic ResT receive(long timeoutMs) throws IOException
timeoutMs
- maximum time to wait before giving up and throwing
a DeadlineExceededException
IOException
- if any error occurspublic void close()
public void cancel()
public Optional<ResT> waitForComplete(long timeoutMs) throws IOException
timeoutMs
- maximum time to wait for server responseIOException
public boolean isOpen()
public boolean isClosed()
public boolean isCanceled()
Copyright © 2023. All Rights Reserved.