Package dk.gtz.graphedit.spi
Class SingleResponseStreamObserver<T>
java.lang.Object
dk.gtz.graphedit.spi.SingleResponseStreamObserver<T>
- Type Parameters:
T
- The type of return value
- All Implemented Interfaces:
io.grpc.stub.StreamObserver<T>
public class SingleResponseStreamObserver<T>
extends Object
implements io.grpc.stub.StreamObserver<T>
Utility class for capturing a single gRPC response and returning it.
Example Usage:
try {
var so = new SingleResponseStreamObserver<GRPCObject>();
stub.get().getValue(empty, so);
so.await();
return so.get();
} catch(InterruptedException e) {
// handle e
}
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a new SingleResponseStreamObserver instance -
Method Summary
-
Constructor Details
-
SingleResponseStreamObserver
public SingleResponseStreamObserver()Constructs a new SingleResponseStreamObserver instance
-
-
Method Details
-
onNext
- Specified by:
onNext
in interfaceio.grpc.stub.StreamObserver<T>
-
onError
- Specified by:
onError
in interfaceio.grpc.stub.StreamObserver<T>
-
onCompleted
public void onCompleted()- Specified by:
onCompleted
in interfaceio.grpc.stub.StreamObserver<T>
-
get
Get the returned value.- Returns:
- An instance of T
- Throws:
RuntimeException
- if an error had occurred or if the value is not present
-
await
Wait for the request to complete.- Throws:
InterruptedException
- if the current thread is interrupted while waiting
-