Class ProxyServiceChannel
java.lang.Object
com.oracle.coherence.grpc.proxy.common.ProxyServiceChannel
- All Implemented Interfaces:
io.grpc.stub.StreamObserver<com.oracle.coherence.grpc.messages.proxy.v1.ProxyRequest>
public class ProxyServiceChannel
extends Object
implements io.grpc.stub.StreamObserver<com.oracle.coherence.grpc.messages.proxy.v1.ProxyRequest>
A bidirectional gRPC channel that handles requests for a gRPC proxy
and sends responses back down the channel.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
An async wrapper around aStreamObserver
.protected class
ProxyServiceChannel.ForwardingStreamObserver<Resp extends com.google.protobuf.Message>
AStreamObserver
used to handle responses from theGrpcServiceProtocol
and convert them to aProxyResponse
to send down the channel. -
Constructor Summary
ConstructorsModifierConstructorDescriptionProxyServiceChannel
(GrpcService service, io.grpc.stub.StreamObserver<com.oracle.coherence.grpc.messages.proxy.v1.ProxyResponse> observer) Create aProxyServiceChannel
.protected
ProxyServiceChannel
(GrpcService service, io.grpc.stub.StreamObserver<com.oracle.coherence.grpc.messages.proxy.v1.ProxyResponse> observer, Supplier<Member> memberSupplier) Create aProxyServiceChannel
. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
Assert that this channel has received anInitRequest
.protected io.grpc.stub.StreamObserver
<com.oracle.coherence.grpc.messages.proxy.v1.ProxyRequest> Return an async wrapper around this channel.Return the serializer being used by the protocol.protected void
init
(long nId, com.oracle.coherence.grpc.messages.proxy.v1.InitRequest request) Initialise this channel.protected static Optional
<GrpcServiceProtocol> loadProtocol
(String sProtocol) Load the requestedGrpcServiceProtocol
.void
void
void
onNext
(com.oracle.coherence.grpc.messages.proxy.v1.ProxyRequest request) protected void
Send an error message down the channel.
-
Constructor Details
-
ProxyServiceChannel
public ProxyServiceChannel(GrpcService service, io.grpc.stub.StreamObserver<com.oracle.coherence.grpc.messages.proxy.v1.ProxyResponse> observer) Create aProxyServiceChannel
.- Parameters:
service
- the parentGrpcService
observer
- theStreamObserver
to send responses to
-
ProxyServiceChannel
protected ProxyServiceChannel(GrpcService service, io.grpc.stub.StreamObserver<com.oracle.coherence.grpc.messages.proxy.v1.ProxyResponse> observer, Supplier<Member> memberSupplier) Create aProxyServiceChannel
.- Parameters:
service
- the parentGrpcService
observer
- theStreamObserver
to send responses tomemberSupplier
- aSupplier
to supply the localMember
-
-
Method Details
-
onNext
public void onNext(com.oracle.coherence.grpc.messages.proxy.v1.ProxyRequest request) - Specified by:
onNext
in interfaceio.grpc.stub.StreamObserver<com.oracle.coherence.grpc.messages.proxy.v1.ProxyRequest>
-
onError
- Specified by:
onError
in interfaceio.grpc.stub.StreamObserver<com.oracle.coherence.grpc.messages.proxy.v1.ProxyRequest>
-
onCompleted
public void onCompleted()- Specified by:
onCompleted
in interfaceio.grpc.stub.StreamObserver<com.oracle.coherence.grpc.messages.proxy.v1.ProxyRequest>
-
getSerializer
Return the serializer being used by the protocol.- Returns:
- the serializer being used by the protocol
-
async
protected io.grpc.stub.StreamObserver<com.oracle.coherence.grpc.messages.proxy.v1.ProxyRequest> async(Executor executor) Return an async wrapper around this channel.- Parameters:
executor
- theExecutor
to use to execute tasks- Returns:
- an async wrapper around this channel
-
init
protected void init(long nId, com.oracle.coherence.grpc.messages.proxy.v1.InitRequest request) Initialise this channel.- Parameters:
nId
- the message id of the init requestrequest
- theInitRequest
to use for initialisation
-
assertInit
protected void assertInit()Assert that this channel has received anInitRequest
.- Throws:
IllegalStateException
- if this channel has not been initialized
-
sendError
Send an error message down the channel.- Parameters:
nId
- the identifier of the request that the error corresponds tothrown
- the error to send
-
loadProtocol
Load the requestedGrpcServiceProtocol
.- Parameters:
sProtocol
- the name of the protocol to load- Returns:
- the requested protocol, or an empty optional if the protocol cannot be loaded
-