Пример #1
0
def early_adopter_create_RouteGuide_stub(host, port, metadata_transformer=None, secure=False, root_certificates=None, private_key=None, certificate_chain=None, server_host_override=None):
  import route_guide_pb2
  import route_guide_pb2
  import route_guide_pb2
  import route_guide_pb2
  import route_guide_pb2
  import route_guide_pb2
  import route_guide_pb2
  import route_guide_pb2
  method_invocation_descriptions = {
    "GetFeature": alpha_utilities.unary_unary_invocation_description(
      route_guide_pb2.Point.SerializeToString,
      route_guide_pb2.Feature.FromString,
    ),
    "ListFeatures": alpha_utilities.unary_stream_invocation_description(
      route_guide_pb2.Rectangle.SerializeToString,
      route_guide_pb2.Feature.FromString,
    ),
    "RecordRoute": alpha_utilities.stream_unary_invocation_description(
      route_guide_pb2.Point.SerializeToString,
      route_guide_pb2.RouteSummary.FromString,
    ),
    "RouteChat": alpha_utilities.stream_stream_invocation_description(
      route_guide_pb2.RouteNote.SerializeToString,
      route_guide_pb2.RouteNote.FromString,
    ),
  }
  return early_adopter_implementations.stub("routeguide.RouteGuide", method_invocation_descriptions, host, port, metadata_transformer=metadata_transformer, secure=secure, root_certificates=root_certificates, private_key=private_key, certificate_chain=certificate_chain, server_host_override=server_host_override)
Пример #2
0
def early_adopter_create_TestService_stub(host, port, metadata_transformer=None, secure=False, root_certificates=None, private_key=None, certificate_chain=None, server_host_override=None):
  import test.cpp.interop.empty_pb2
  import test.cpp.interop.empty_pb2
  import test.cpp.interop.messages_pb2
  import test.cpp.interop.messages_pb2
  import test.cpp.interop.messages_pb2
  import test.cpp.interop.messages_pb2
  import test.cpp.interop.messages_pb2
  import test.cpp.interop.messages_pb2
  import test.cpp.interop.messages_pb2
  import test.cpp.interop.messages_pb2
  import test.cpp.interop.messages_pb2
  import test.cpp.interop.messages_pb2
  method_invocation_descriptions = {
    "EmptyCall": utilities.unary_unary_invocation_description(
      test.cpp.interop.empty_pb2.Empty.SerializeToString,
      test.cpp.interop.empty_pb2.Empty.FromString,
    ),
    "FullDuplexCall": utilities.stream_stream_invocation_description(
      test.cpp.interop.messages_pb2.StreamingOutputCallRequest.SerializeToString,
      test.cpp.interop.messages_pb2.StreamingOutputCallResponse.FromString,
    ),
    "HalfDuplexCall": utilities.stream_stream_invocation_description(
      test.cpp.interop.messages_pb2.StreamingOutputCallRequest.SerializeToString,
      test.cpp.interop.messages_pb2.StreamingOutputCallResponse.FromString,
    ),
    "StreamingInputCall": utilities.stream_unary_invocation_description(
      test.cpp.interop.messages_pb2.StreamingInputCallRequest.SerializeToString,
      test.cpp.interop.messages_pb2.StreamingInputCallResponse.FromString,
    ),
    "StreamingOutputCall": utilities.unary_stream_invocation_description(
      test.cpp.interop.messages_pb2.StreamingOutputCallRequest.SerializeToString,
      test.cpp.interop.messages_pb2.StreamingOutputCallResponse.FromString,
    ),
    "UnaryCall": utilities.unary_unary_invocation_description(
      test.cpp.interop.messages_pb2.SimpleRequest.SerializeToString,
      test.cpp.interop.messages_pb2.SimpleResponse.FromString,
    ),
  }
  return implementations.stub("grpc.testing.TestService", method_invocation_descriptions, host, port, metadata_transformer=metadata_transformer, secure=secure, root_certificates=root_certificates, private_key=private_key, certificate_chain=certificate_chain, server_host_override=server_host_override)
Пример #3
0
def early_adopter_create_RouteGuide_stub(host,
                                         port,
                                         metadata_transformer=None,
                                         secure=False,
                                         root_certificates=None,
                                         private_key=None,
                                         certificate_chain=None,
                                         server_host_override=None):
    import route_guide_pb2
    import route_guide_pb2
    import route_guide_pb2
    import route_guide_pb2
    import route_guide_pb2
    import route_guide_pb2
    import route_guide_pb2
    import route_guide_pb2
    method_invocation_descriptions = {
        "GetFeature":
        alpha_utilities.unary_unary_invocation_description(
            route_guide_pb2.Point.SerializeToString,
            route_guide_pb2.Feature.FromString,
        ),
        "ListFeatures":
        alpha_utilities.unary_stream_invocation_description(
            route_guide_pb2.Rectangle.SerializeToString,
            route_guide_pb2.Feature.FromString,
        ),
        "RecordRoute":
        alpha_utilities.stream_unary_invocation_description(
            route_guide_pb2.Point.SerializeToString,
            route_guide_pb2.RouteSummary.FromString,
        ),
        "RouteChat":
        alpha_utilities.stream_stream_invocation_description(
            route_guide_pb2.RouteNote.SerializeToString,
            route_guide_pb2.RouteNote.FromString,
        ),
    }
    return early_adopter_implementations.stub(
        "routeguide.RouteGuide",
        method_invocation_descriptions,
        host,
        port,
        metadata_transformer=metadata_transformer,
        secure=secure,
        root_certificates=root_certificates,
        private_key=private_key,
        certificate_chain=certificate_chain,
        server_host_override=server_host_override)
Пример #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(
Пример #5
0
    messages_pb2.StreamingInputCallResponse.FromString)
_SERVER_STREAMING_INPUT_CALL = utilities.stream_unary_service_description(
    _streaming_input_call,
    messages_pb2.StreamingInputCallRequest.FromString,
    messages_pb2.StreamingInputCallResponse.SerializeToString)


def _full_duplex_call(request_iterator, unused_context):
  for request in request_iterator:
    yield messages_pb2.StreamingOutputCallResponse(
        payload=messages_pb2.Payload(
            type=request.payload.type,
            body=b'\x00' * request.response_parameters[0].size))

_CLIENT_FULL_DUPLEX_CALL = utilities.stream_stream_invocation_description(
    messages_pb2.StreamingOutputCallRequest.SerializeToString,
    messages_pb2.StreamingOutputCallResponse.FromString)
_SERVER_FULL_DUPLEX_CALL = utilities.stream_stream_service_description(
    _full_duplex_call,
    messages_pb2.StreamingOutputCallRequest.FromString,
    messages_pb2.StreamingOutputCallResponse.SerializeToString)

# NOTE(nathaniel): Apparently this is the same as the full-duplex call?
_CLIENT_HALF_DUPLEX_CALL = utilities.stream_stream_invocation_description(
    messages_pb2.StreamingOutputCallRequest.SerializeToString,
    messages_pb2.StreamingOutputCallResponse.FromString)
_SERVER_HALF_DUPLEX_CALL = utilities.stream_stream_service_description(
    _full_duplex_call,
    messages_pb2.StreamingOutputCallRequest.FromString,
    messages_pb2.StreamingOutputCallResponse.SerializeToString)
Пример #6
0
def _fib(request, unused_context):
  for number in _fibbonacci(request.limit):
    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),
Пример #7
0
def early_adopter_create_TestService_stub(host,
                                          port,
                                          metadata_transformer=None,
                                          secure=False,
                                          root_certificates=None,
                                          private_key=None,
                                          certificate_chain=None,
                                          server_host_override=None):
    import test.cpp.interop.empty_pb2
    import test.cpp.interop.empty_pb2
    import test.cpp.interop.messages_pb2
    import test.cpp.interop.messages_pb2
    import test.cpp.interop.messages_pb2
    import test.cpp.interop.messages_pb2
    import test.cpp.interop.messages_pb2
    import test.cpp.interop.messages_pb2
    import test.cpp.interop.messages_pb2
    import test.cpp.interop.messages_pb2
    import test.cpp.interop.messages_pb2
    import test.cpp.interop.messages_pb2
    method_invocation_descriptions = {
        "EmptyCall":
        utilities.unary_unary_invocation_description(
            test.cpp.interop.empty_pb2.Empty.SerializeToString,
            test.cpp.interop.empty_pb2.Empty.FromString,
        ),
        "FullDuplexCall":
        utilities.stream_stream_invocation_description(
            test.cpp.interop.messages_pb2.StreamingOutputCallRequest.
            SerializeToString,
            test.cpp.interop.messages_pb2.StreamingOutputCallResponse.
            FromString,
        ),
        "HalfDuplexCall":
        utilities.stream_stream_invocation_description(
            test.cpp.interop.messages_pb2.StreamingOutputCallRequest.
            SerializeToString,
            test.cpp.interop.messages_pb2.StreamingOutputCallResponse.
            FromString,
        ),
        "StreamingInputCall":
        utilities.stream_unary_invocation_description(
            test.cpp.interop.messages_pb2.StreamingInputCallRequest.
            SerializeToString,
            test.cpp.interop.messages_pb2.StreamingInputCallResponse.
            FromString,
        ),
        "StreamingOutputCall":
        utilities.unary_stream_invocation_description(
            test.cpp.interop.messages_pb2.StreamingOutputCallRequest.
            SerializeToString,
            test.cpp.interop.messages_pb2.StreamingOutputCallResponse.
            FromString,
        ),
        "UnaryCall":
        utilities.unary_unary_invocation_description(
            test.cpp.interop.messages_pb2.SimpleRequest.SerializeToString,
            test.cpp.interop.messages_pb2.SimpleResponse.FromString,
        ),
    }
    return implementations.stub("grpc.testing.TestService",
                                method_invocation_descriptions,
                                host,
                                port,
                                metadata_transformer=metadata_transformer,
                                secure=secure,
                                root_certificates=root_certificates,
                                private_key=private_key,
                                certificate_chain=certificate_chain,
                                server_host_override=server_host_override)