ReqT - type of the requestResT - type of the response@NotThreadSafe
public class GrpcBlockingStream<ReqT,ResT>
extends java.lang.Object
| Constructor and Description |
|---|
GrpcBlockingStream(java.util.function.Function<io.grpc.stub.StreamObserver<ResT>,io.grpc.stub.StreamObserver<ReqT>> rpcFunc,
int bufferSize,
java.lang.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.
|
void |
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, java.lang.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 java.io.IOException
request - the requesttimeoutMs - maximum wait time before throwing a DeadlineExceededExceptionjava.io.IOException - if any error occurspublic void send(ReqT request) throws java.io.IOException
request - the requestjava.io.IOException - if any error occurspublic ResT receive(long timeoutMs) throws java.io.IOException
timeoutMs - maximum time to wait before giving up and throwing
a DeadlineExceededExceptionjava.io.IOException - if any error occurspublic void close()
public void cancel()
public void waitForComplete(long timeoutMs)
throws java.io.IOException
timeoutMs - maximum time to wait for server responsejava.io.IOExceptionpublic boolean isOpen()
public boolean isClosed()
public boolean isCanceled()
Copyright © 2022. All Rights Reserved.