public class FnApiControlClient extends java.lang.Object implements java.io.Closeable, InstructionRequestHandler
This class presents a low-level Java API de-inverting the Fn API's gRPC layer.
The Fn API is inverted so the runner is the server and the SDK harness is the client, for firewalling reasons (the runner may execute in a more privileged environment forbidding outbound connections).
This low-level client is responsible only for correlating requests with responses.
Modifier and Type | Method and Description |
---|---|
org.apache.beam.vendor.grpc.v1p21p0.io.grpc.stub.StreamObserver<org.apache.beam.model.fnexecution.v1.BeamFnApi.InstructionResponse> |
asResponseObserver() |
void |
close() |
static FnApiControlClient |
forRequestObserver(java.lang.String workerId,
org.apache.beam.vendor.grpc.v1p21p0.io.grpc.stub.StreamObserver<org.apache.beam.model.fnexecution.v1.BeamFnApi.InstructionRequest> requestObserver)
Returns a
FnApiControlClient which will submit its requests to the provided observer. |
java.lang.String |
getWorkerId() |
java.util.concurrent.CompletionStage<org.apache.beam.model.fnexecution.v1.BeamFnApi.InstructionResponse> |
handle(org.apache.beam.model.fnexecution.v1.BeamFnApi.InstructionRequest request) |
void |
onClose(java.util.function.Consumer<FnApiControlClient> onCloseListener) |
public static FnApiControlClient forRequestObserver(java.lang.String workerId, org.apache.beam.vendor.grpc.v1p21p0.io.grpc.stub.StreamObserver<org.apache.beam.model.fnexecution.v1.BeamFnApi.InstructionRequest> requestObserver)
FnApiControlClient
which will submit its requests to the provided observer.
It is the responsibility of the caller to register this object as an observer of incoming responses (this will generally be done as part of fulfilling the contract of a gRPC service).
public java.util.concurrent.CompletionStage<org.apache.beam.model.fnexecution.v1.BeamFnApi.InstructionResponse> handle(org.apache.beam.model.fnexecution.v1.BeamFnApi.InstructionRequest request)
handle
in interface InstructionRequestHandler
public org.apache.beam.vendor.grpc.v1p21p0.io.grpc.stub.StreamObserver<org.apache.beam.model.fnexecution.v1.BeamFnApi.InstructionResponse> asResponseObserver()
public void close()
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
public java.lang.String getWorkerId()
public void onClose(java.util.function.Consumer<FnApiControlClient> onCloseListener)