public class StreamObservers
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static void |
ack(io.grpc.stub.StreamObserver<io.spine.core.Response> responseObserver)
A utility method which sends acknowledgement
to the client via the
responseObserver provided and
completes the response. |
static java.util.Optional<io.spine.base.Error> |
fromStreamError(java.lang.Throwable throwable)
Extracts a system error from the
Throwable
received on a client-side as a result of a failed gRPC call to server-side routines.
|
static <T> io.grpc.stub.StreamObserver<T> |
noOpObserver()
Creates a observer which does nothing upon
the invocation of its callback methods.
|
public static <T> io.grpc.stub.StreamObserver<T> noOpObserver()
The callees which do not want to follow the responses should use this utility method to eliminate boilerplate code.
StreamObserver
which does nothingpublic static void ack(io.grpc.stub.StreamObserver<io.spine.core.Response> responseObserver)
responseObserver
provided and
completes the response.public static java.util.Optional<io.spine.base.Error> fromStreamError(java.lang.Throwable throwable)
The Error
is extracted from the trailer metadata of
either StatusRuntimeException
or StatusException
only.
If any other type of Throwable
is passed, Optional.empty()
is returned.
throwable
- the Throwable
to extract an Error
Optional.empty()
if the extraction failed