jina.peapods.grpc package

Module contents

class jina.peapods.grpc.Grpclet(args, message_callback, logger=None)[source]

Bases: jina.proto.jina_pb2_grpc.JinaDataRequestRPCServicer

A Grpclet object can send/receive Messages via gRPC.

  • args (Namespace) – the parsed arguments from the CLI

  • message_callback (Callable[[Message], None]) – the callback to call on received messages

  • logger (Optional[JinaLogger]) – the logger to use

async send_message(msg, **kwargs)[source]

Sends a message via gRPC to the target indicated in the message’s routing table :type msg: Message :param msg: the protobuf message to send :param kwargs: Additional arguments.

static send_ctrl_msg(pod_address, command, timeout=1.0)[source]

Sends a control message via gRPC to pod_address :type pod_address: str :param pod_address: the pod to send the command to :type command: str :param command: the command to send (TERMINATE/ACTIVATE/…) :param timeout: optional timeout for the request in seconds :returns: Empty protobuf struct

async close(grace_period=None, *args, **kwargs)[source]

Stop the Grpc server :param grace_period: Time to wait for message processing to finish before killing the grpc server :param args: Extra positional arguments :param kwargs: Extra key-value arguments

async start()[source]

Starts this Grpclet by starting its gRPC server

async Call(msg, *args)[source]

Processes messages received by the GRPC server :param msg: The received message :param args: Extra positional arguments :return: Empty protobuf struct, necessary to return for protobuf Empty