Class ProtocolHandler
java.lang.Object
org.hansken.plugin.extraction.runtime.grpc.client.ProtocolHandler
- All Implemented Interfaces:
io.grpc.stub.StreamObserver<com.google.protobuf.Any>
public class ProtocolHandler
extends Object
implements io.grpc.stub.StreamObserver<com.google.protobuf.Any>
Handler for orchestrating the processing of a
trace over gRPC, which itself
is an observer for a stream in order to receive messages from the server.-
Constructor Summary
ConstructorsConstructorDescriptionProtocolHandler(ReplyStream replyStream, ExtractionPluginGrpcAdapter adapter) Initialize a handler for processing atraceover gRPC. -
Method Summary
Modifier and TypeMethodDescriptionvoidawait()Blocks and waits for the processing of thetraceto be finished, whether or not due to an error.voidvoidCallable that processes errors.voidonNext(com.google.protobuf.Any message) voidstart(Trace trace, DataContext context) Sends the START message sent over the communication streams.
-
Constructor Details
-
ProtocolHandler
Initialize a handler for processing atraceover gRPC.- Parameters:
replyStream- the outbound message streamadapter- the adapter which can execute the received messages
-
-
Method Details
-
start
Sends the START message sent over the communication streams. This message is defined in the gRPC protocol. When the ExtractionPlugin receives this message it actually starts the process method.- Parameters:
trace- the trace to processcontext- the context to process
-
await
public void await()Blocks and waits for the processing of thetraceto be finished, whether or not due to an error.- Throws:
RuntimeException- any exception that occured during remote processing
-
onNext
public void onNext(com.google.protobuf.Any message) - Specified by:
onNextin interfaceio.grpc.stub.StreamObserver<com.google.protobuf.Any>
-
onError
Callable that processes errors.This method will _not_ signal the remote server that there was an exception, and thus this method will not disconnect from the server. Please use setErrorFromInternal() if the error cause was from an internal routine and a disconnect should be triggered.
Since we are in error state, no new incoming messages are expected. Therefore onError() lowers a latch so that await() finishes. The throwable passed to this method will bubble back to the caller of await().
- Specified by:
onErrorin interfaceio.grpc.stub.StreamObserver<com.google.protobuf.Any>- Parameters:
t- error that occured.
-
onCompleted
public void onCompleted()- Specified by:
onCompletedin interfaceio.grpc.stub.StreamObserver<com.google.protobuf.Any>
-