Esempio n. 1
0
    def FromString(x: bytes):
        """
        # noqa: DAR101
        # noqa: DAR102
        # noqa: DAR201
        """
        proto = jina_pb2.ControlRequestProto()
        proto.ParseFromString(x)

        return ControlRequest(request=proto)
Esempio n. 2
0
    def __init__(
        self,
        command: Optional[str] = None,
        request: Optional['jina_pb2.jina_pb2.ControlRequestProto'] = None,
    ):

        if isinstance(request, jina_pb2.ControlRequestProto):
            self._pb_body = request
        elif request is not None:
            # note ``None`` is not considered as a bad type
            raise ValueError(f'{typename(request)} is not recognizable')
        if command:
            proto = jina_pb2.ControlRequestProto()
            proto.header.request_id = random_identity()
            if command in _available_commands:
                proto.command = getattr(jina_pb2.ControlRequestProto, command)
            else:
                raise ValueError(
                    f'command "{command}" is not supported, must be one of {_available_commands}'
                )
            self._pb_body = proto
Esempio n. 3
0
def control_req():
    r = jina_pb2.ControlRequestProto()
    r.header.request_id = random_identity()
    return r