Пример #1
0
def early_adopter_create_Vtctl_stub(host, port):
  import vtctl_pb2
  import vtctl_pb2
  method_invocation_descriptions = {
    "ExecuteVtctlCommand": utilities.unary_stream_invocation_description(
      vtctl_pb2.ExecuteVtctlCommandArgs.SerializeToString,
      vtctl_pb2.LoggerEvent.FromString,
    ),
  }
  return implementations.insecure_stub(method_invocation_descriptions, host, port)
Пример #2
0
def early_adopter_create_Vtctl_stub(host, port):
    import vtctl_pb2
    import vtctl_pb2
    method_invocation_descriptions = {
        "ExecuteVtctlCommand":
        utilities.unary_stream_invocation_description(
            vtctl_pb2.ExecuteVtctlCommandArgs.SerializeToString,
            vtctl_pb2.LoggerEvent.FromString,
        ),
    }
    return implementations.insecure_stub(method_invocation_descriptions, host,
                                         port)
Пример #3
0
def _sum(request_iterator, unused_context):
    accumulation = 0
    for request in request_iterator:
        accumulation += request.num
    return math_pb2.Num(num=accumulation)


_INVOCATION_DESCRIPTIONS = {
    DIV:
    utilities.unary_unary_invocation_description(
        math_pb2.DivArgs.SerializeToString, math_pb2.DivReply.FromString),
    DIV_MANY:
    utilities.stream_stream_invocation_description(
        math_pb2.DivArgs.SerializeToString, math_pb2.DivReply.FromString),
    FIB:
    utilities.unary_stream_invocation_description(
        math_pb2.FibArgs.SerializeToString, math_pb2.Num.FromString),
    SUM:
    utilities.stream_unary_invocation_description(
        math_pb2.Num.SerializeToString, math_pb2.Num.FromString),
}

_SERVICE_DESCRIPTIONS = {
    DIV:
    utilities.unary_unary_service_description(
        _div, math_pb2.DivArgs.FromString,
        math_pb2.DivReply.SerializeToString),
    DIV_MANY:
    utilities.stream_stream_service_description(
        _div_many, math_pb2.DivArgs.FromString,
        math_pb2.DivReply.SerializeToString),
    FIB:
Пример #4
0
    yield math_pb2.Num(num=number)


def _sum(request_iterator, unused_context):
  accumulation = 0
  for request in request_iterator:
    accumulation += request.num
  return math_pb2.Num(num=accumulation)


_INVOCATION_DESCRIPTIONS = {
    DIV: utilities.unary_unary_invocation_description(
        math_pb2.DivArgs.SerializeToString, math_pb2.DivReply.FromString),
    DIV_MANY: utilities.stream_stream_invocation_description(
        math_pb2.DivArgs.SerializeToString, math_pb2.DivReply.FromString),
    FIB: utilities.unary_stream_invocation_description(
        math_pb2.FibArgs.SerializeToString, math_pb2.Num.FromString),
    SUM: utilities.stream_unary_invocation_description(
        math_pb2.Num.SerializeToString, math_pb2.Num.FromString),
}

_SERVICE_DESCRIPTIONS = {
    DIV: utilities.unary_unary_service_description(
        _div, math_pb2.DivArgs.FromString,
        math_pb2.DivReply.SerializeToString),
    DIV_MANY: utilities.stream_stream_service_description(
        _div_many, math_pb2.DivArgs.FromString,
        math_pb2.DivReply.SerializeToString),
    FIB: utilities.unary_stream_service_description(
        _fib, math_pb2.FibArgs.FromString, math_pb2.Num.SerializeToString),
    SUM: utilities.stream_unary_service_description(
        _sum, math_pb2.Num.FromString, math_pb2.Num.SerializeToString),
Пример #5
0
    messages_pb2.SimpleResponse.FromString)
_SERVER_UNARY_CALL = utilities.unary_unary_service_description(
    _unary_call, messages_pb2.SimpleRequest.FromString,
    messages_pb2.SimpleResponse.SerializeToString)


def _streaming_output_call(request, unused_context):
    for response_parameters in request.response_parameters:
        yield messages_pb2.StreamingOutputCallResponse(
            payload=messages_pb2.Payload(type=request.response_type,
                                         body=b'\x00' *
                                         response_parameters.size))


_CLIENT_STREAMING_OUTPUT_CALL = utilities.unary_stream_invocation_description(
    messages_pb2.StreamingOutputCallRequest.SerializeToString,
    messages_pb2.StreamingOutputCallResponse.FromString)
_SERVER_STREAMING_OUTPUT_CALL = utilities.unary_stream_service_description(
    _streaming_output_call, messages_pb2.StreamingOutputCallRequest.FromString,
    messages_pb2.StreamingOutputCallResponse.SerializeToString)


def _streaming_input_call(request_iterator, unused_context):
    aggregate_size = 0
    for request in request_iterator:
        if request.payload and request.payload.body:
            aggregate_size += len(request.payload.body)
    return messages_pb2.StreamingInputCallResponse(
        aggregated_payload_size=aggregate_size)

Пример #6
0
    messages_pb2.SimpleRequest.SerializeToString,
    messages_pb2.SimpleResponse.FromString)
_SERVER_UNARY_CALL = utilities.unary_unary_service_description(
    _unary_call, messages_pb2.SimpleRequest.FromString,
    messages_pb2.SimpleResponse.SerializeToString)


def _streaming_output_call(request, unused_context):
  for response_parameters in request.response_parameters:
    yield messages_pb2.StreamingOutputCallResponse(
        payload=messages_pb2.Payload(
            type=request.response_type,
            body=b'\x00' * response_parameters.size))

_CLIENT_STREAMING_OUTPUT_CALL = utilities.unary_stream_invocation_description(
    messages_pb2.StreamingOutputCallRequest.SerializeToString,
    messages_pb2.StreamingOutputCallResponse.FromString)
_SERVER_STREAMING_OUTPUT_CALL = utilities.unary_stream_service_description(
    _streaming_output_call,
    messages_pb2.StreamingOutputCallRequest.FromString,
    messages_pb2.StreamingOutputCallResponse.SerializeToString)


def _streaming_input_call(request_iterator, unused_context):
  aggregate_size = 0
  for request in request_iterator:
    if request.payload and request.payload.body:
      aggregate_size += len(request.payload.body)
  return messages_pb2.StreamingInputCallResponse(
      aggregated_payload_size=aggregate_size)