narupa.core.grpc_client module

Module providing a base class for gRPC clients.

class narupa.core.grpc_client.GrpcClient(*, channel: grpc.Channel, make_channel_owner: bool = False, **kwargs)

Bases: object

A base class for GRPC clients that handles service connection and client closing.

Parameters:
  • channel – An existing grpc.Channel to use to establish a connection.
  • make_channel_owner – Whether to make this client take ownership of ensuring the channel is closed upon disconnection of this client.
DEFAULT_CONNECTION_PORT = 54321
close()

Shutdown all threads and close the underlying channel if the client has been given that responsibility.

classmethod insecure_channel(*, address: Optional[str] = None, port: Optional[int] = None, **kwargs)

Create an insecure connection at the given address and port.

Parameters:
  • address – The URL or IP address of the service to connect to.
  • port – The port on which to connect.
Returns:

An instantiation of a client connected insecurely at the given address and port.

is_channel_owner

Indicates whether this client is responsible for managing the underlying channel.

Returns:True if this client is responsible for managing the underlying channel, False otherwise.