Package com.oracle.coherence.grpc.proxy
Class ResponseHandlers
- java.lang.Object
- 
- com.oracle.coherence.grpc.proxy.ResponseHandlers
 
- 
 public class ResponseHandlers extends Object Helper methods to handle gRPC async responses.- Since:
- 23.03
- Author:
- Jonathan Knight 2023.02.02
 
- 
- 
Constructor SummaryConstructors Constructor Description ResponseHandlers()
 - 
Method SummaryAll Methods Static Methods Concrete Methods Modifier and Type Method Description static <Resp> VoidhandleError(Throwable err, io.grpc.stub.StreamObserver<Resp> observer)A handler method that will callStreamObserver.onError(Throwable)if the error parameter is notnull.static <Resp> ResphandleError(Resp response, Throwable err)A handler method that will return the response if there is no error or if there is an error then ensure that it is aStatusRuntimeException.static <Resp> VoidhandleErrorOrComplete(Throwable err, io.grpc.stub.StreamObserver<Resp> observer)A handler method that will callStreamObserver.onError(Throwable)if the error parameter is notnullotherwise callsStreamObserver.onCompleted().static VoidhandleMapOfEntries(RequestHolder<?,Map<Binary,Binary>> holder, Throwable err, io.grpc.stub.StreamObserver<com.oracle.coherence.grpc.Entry> observer)Handle the result of the asynchronous invoke all request sending the results, or any errors to theStreamObserver.static VoidhandleMapOfEntries(RequestHolder<?,Map<Binary,Binary>> holder, Throwable err, io.grpc.stub.StreamObserver<com.oracle.coherence.grpc.Entry> observer, boolean fDeserialize)Handle the result of the asynchronous invoke all request sending the results, or any errors to theStreamObserver.static VoidhandleSetOfEntries(RequestHolder<?,Set<Map.Entry<Binary,Binary>>> holder, Throwable err, io.grpc.stub.StreamObserver<com.oracle.coherence.grpc.Entry> observer)Handle the result of the asynchronous entry set request sending the results, or any errors to theStreamObserver.static VoidhandleSetOfEntries(RequestHolder<?,Set<Map.Entry<Binary,Binary>>> holder, Throwable err, io.grpc.stub.StreamObserver<com.oracle.coherence.grpc.Entry> observer, boolean fDeserialize)Handle the result of the asynchronous entry set request sending the results, or any errors to theStreamObserver.static VoidhandleStream(RequestHolder<?,? extends Iterable<Binary>> holder, Throwable err, io.grpc.stub.StreamObserver<com.google.protobuf.BytesValue> observer)static <Resp> VoidhandleStream(Iterable<Resp> iterable, Throwable err, io.grpc.stub.StreamObserver<Resp> observer)A handler method that streams results from anIterableto aStreamObserverand completes theStreamObserver, or if an error is provided callsStreamObserver.onError(Throwable).static <Resp> VoidhandleStream(Stream<Resp> stream, Throwable err, io.grpc.stub.StreamObserver<Resp> observer)A handler method that streams results to aStreamObserverand completes theStreamObserveror if an error is provided callsStreamObserver.onError(Throwable).static voidhandleStreamOfEntries(RequestHolder<?,?> holder, Stream<Map.Entry<Binary,Binary>> entries, io.grpc.stub.StreamObserver<com.oracle.coherence.grpc.Entry> observer)Handle the result of the asynchronous invoke all request sending the results, or any errors to theStreamObserver.static voidhandleStreamOfEntries(RequestHolder<?,?> holder, Stream<Map.Entry<Binary,Binary>> entries, io.grpc.stub.StreamObserver<com.oracle.coherence.grpc.Entry> observer, boolean fDeserialize)Handle the result of the asynchronous invoke all request sending the results, or any errors to theStreamObserver.static <R> VoidhandleUnary(R result, Throwable err, io.grpc.stub.StreamObserver<R> observer)Handle an unary request.static com.google.protobuf.Int32ValuetoInt32Value(Object o)Convert a value to anInt32Value.
 
- 
- 
- 
Method Detail- 
handleUnarypublic static <R> Void handleUnary(R result, Throwable err, io.grpc.stub.StreamObserver<R> observer) Handle an unary request.- Type Parameters:
- R- the type of the result
- Parameters:
- result- the result
- err- any error that may have occurred
- observer- the- StreamObserverto send the result to
- Returns:
- always returns Void
 
 - 
handleMapOfEntriespublic static Void handleMapOfEntries(RequestHolder<?,Map<Binary,Binary>> holder, Throwable err, io.grpc.stub.StreamObserver<com.oracle.coherence.grpc.Entry> observer) Handle the result of the asynchronous invoke all request sending the results, or any errors to theStreamObserver.- Parameters:
- holder- the- RequestHoldercontaining the request
- err- any error that occurred during execution of the get all request
- observer- the- StreamObserverto receive the results
- Returns:
- always return Void
 
 - 
handleMapOfEntriespublic static Void handleMapOfEntries(RequestHolder<?,Map<Binary,Binary>> holder, Throwable err, io.grpc.stub.StreamObserver<com.oracle.coherence.grpc.Entry> observer, boolean fDeserialize) Handle the result of the asynchronous invoke all request sending the results, or any errors to theStreamObserver.- Parameters:
- holder- the- RequestHoldercontaining the request
- err- any error that occurred during execution of the get all request
- observer- the- StreamObserverto receive the results
- fDeserialize- a flag indicating whether the- Binaryvalues should be deserialized
- Returns:
- always return Void
 
 - 
handleSetOfEntriespublic static Void handleSetOfEntries(RequestHolder<?,Set<Map.Entry<Binary,Binary>>> holder, Throwable err, io.grpc.stub.StreamObserver<com.oracle.coherence.grpc.Entry> observer) Handle the result of the asynchronous entry set request sending the results, or any errors to theStreamObserver.- Parameters:
- holder- the- RequestHoldercontaining the request
- err- any error that occurred during execution of the get all request
- observer- the- StreamObserverto receive the results
- fDeserialize- a flag indicating whether the- Binaryvalues should be deserialized
- Returns:
- always return Void
 
 - 
handleSetOfEntriespublic static Void handleSetOfEntries(RequestHolder<?,Set<Map.Entry<Binary,Binary>>> holder, Throwable err, io.grpc.stub.StreamObserver<com.oracle.coherence.grpc.Entry> observer, boolean fDeserialize) Handle the result of the asynchronous entry set request sending the results, or any errors to theStreamObserver.- Parameters:
- holder- the- RequestHoldercontaining the request
- err- any error that occurred during execution of the get all request
- observer- the- StreamObserverto receive the results
- fDeserialize- a flag indicating whether the- Binaryvalues should be deserialized
- Returns:
- always return Void
 
 - 
handleStreamOfEntriespublic static void handleStreamOfEntries(RequestHolder<?,?> holder, Stream<Map.Entry<Binary,Binary>> entries, io.grpc.stub.StreamObserver<com.oracle.coherence.grpc.Entry> observer) Handle the result of the asynchronous invoke all request sending the results, or any errors to theStreamObserver.- Parameters:
- holder- the- RequestHoldercontaining the request
- entries- a- Streamof entries
- observer- the- StreamObserverto receive the results
 
 - 
handleStreamOfEntriespublic static void handleStreamOfEntries(RequestHolder<?,?> holder, Stream<Map.Entry<Binary,Binary>> entries, io.grpc.stub.StreamObserver<com.oracle.coherence.grpc.Entry> observer, boolean fDeserialize) Handle the result of the asynchronous invoke all request sending the results, or any errors to theStreamObserver.- Parameters:
- holder- the- RequestHoldercontaining the request
- entries- a- Streamof entries
- observer- the- StreamObserverto receive the results
- fDeserialize- a flag indicating whether the- Binaryvalues should be deserialized
 
 - 
handleStreampublic static Void handleStream(RequestHolder<?,? extends Iterable<Binary>> holder, Throwable err, io.grpc.stub.StreamObserver<com.google.protobuf.BytesValue> observer) Send anIterableofBinaryinstances to aStreamObserver, converting theBinaryinstances to aBytesValue.- Parameters:
- holder- the- RequestHoldercontaining the request and- Iterableor- Binaryinstances to stream
- err- the error the pass to- StreamObserver.onError(Throwable)
- observer- the- StreamObserverto receive the results
- Returns:
- always return Void
 
 - 
handleStreampublic static <Resp> Void handleStream(Iterable<Resp> iterable, Throwable err, io.grpc.stub.StreamObserver<Resp> observer) A handler method that streams results from anIterableto aStreamObserverand completes theStreamObserver, or if an error is provided callsStreamObserver.onError(Throwable).Note: this method will complete by calling either StreamObserver.onCompleted()orStreamObserver.onError(Throwable).- Type Parameters:
- Resp- the type of the element to stream to the- StreamObserver
- Parameters:
- iterable- the elements to stream to the- StreamObserver
- err- the error the pass to- StreamObserver.onError(Throwable)
- observer- the- StreamObserver
- Returns:
- always returns Void
 
 - 
handleStreampublic static <Resp> Void handleStream(Stream<Resp> stream, Throwable err, io.grpc.stub.StreamObserver<Resp> observer) A handler method that streams results to aStreamObserverand completes theStreamObserveror if an error is provided callsStreamObserver.onError(Throwable).Note: this method will complete by calling either StreamObserver.onCompleted()orStreamObserver.onError(Throwable).- Type Parameters:
- Resp- the type of the element to stream to the- StreamObserver
- Parameters:
- stream- the elements to stream to the- StreamObserver
- err- the error the pass to- StreamObserver.onError(Throwable)
- observer- the- StreamObserver
- Returns:
- always returns Void
 
 - 
handleErrorpublic static <Resp> Void handleError(Throwable err, io.grpc.stub.StreamObserver<Resp> observer) A handler method that will callStreamObserver.onError(Throwable)if the error parameter is notnull.NOTE: this method will not complete the StreamObserverif there is no error.- Type Parameters:
- Resp- the type of the element to stream to the- StreamObserver
- Parameters:
- err- the error the pass to- StreamObserver.onError(Throwable)
- observer- the- StreamObserver
- Returns:
- always returns Void
 
 - 
handleErrorOrCompletepublic static <Resp> Void handleErrorOrComplete(Throwable err, io.grpc.stub.StreamObserver<Resp> observer) A handler method that will callStreamObserver.onError(Throwable)if the error parameter is notnullotherwise callsStreamObserver.onCompleted().NOTE: this method will not complete the StreamObserverif there is no error.- Type Parameters:
- Resp- the type of the element to stream to the- StreamObserver
- Parameters:
- err- the error the pass to- StreamObserver.onError(Throwable)
- observer- the- StreamObserver
- Returns:
- always returns Void
 
 - 
handleErrorpublic static <Resp> Resp handleError(Resp response, Throwable err)A handler method that will return the response if there is no error or if there is an error then ensure that it is aStatusRuntimeException.- Type Parameters:
- Resp- the type of the response
- Parameters:
- response- the response to return if there is no error
- err- the error to check
- Returns:
- always returns the passed in response
 
 
- 
 
-