teos.rpc

class RPC(rpc_bind, rpc_port, internal_api_endpoint)[source]

Bases: object

The RPC is an external RPC server offered by tower to receive requests from the CLI. This acts as a proxy between the internal api and the CLI.

Parameters
  • rpc_bind (str) – the IP or host where the RPC server will be hosted.

  • rpc_port (int) – the port where the RPC server will be hosted.

  • internal_api_endpoint (str) – the endpoint where to reach the internal (gRPC) api.

logger

The logger for this component.

Type

Logger

endpoint

The endpoint where the RPC api will be served (external gRPC server).

Type

str

rpc_server

The non-started gRPC server instance.

Type

grpc.Server

handle_signals(signum, frame)[source]

Ignores CTRL + C since and let’s the main process manage the teardown.

teardown()[source]
forward_errors(func)[source]

Transforms func in order to forward any grpc.RPCError returned by the upstream grpc as the result of the current grpc call.

serve(rpc_bind, rpc_port, internal_api_endpoint, stop_event, log_file)[source]

Serves the external RPC API at the given endpoint and connects it to the internal api.

This method will serve and hold until the main process is stop or a stop signal is received.

Parameters
  • rpc_bind (str) – the IP or host where the RPC server will be hosted.

  • rpc_port (int) – the port where the RPC server will be hosted.

  • internal_api_endpoint (str) – the endpoint where to reach the internal (gRPC) api.

  • stop_event (multiprocessing.Event) – initiate a graceful shutdown once this event is set.