Пример #1
0
def early_adopter_create_RouteGuide_server(servicer, port, private_key=None, certificate_chain=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_service_descriptions = {
    "GetFeature": alpha_utilities.unary_unary_service_description(
      servicer.GetFeature,
      route_guide_pb2.Point.FromString,
      route_guide_pb2.Feature.SerializeToString,
    ),
    "ListFeatures": alpha_utilities.unary_stream_service_description(
      servicer.ListFeatures,
      route_guide_pb2.Rectangle.FromString,
      route_guide_pb2.Feature.SerializeToString,
    ),
    "RecordRoute": alpha_utilities.stream_unary_service_description(
      servicer.RecordRoute,
      route_guide_pb2.Point.FromString,
      route_guide_pb2.RouteSummary.SerializeToString,
    ),
    "RouteChat": alpha_utilities.stream_stream_service_description(
      servicer.RouteChat,
      route_guide_pb2.RouteNote.FromString,
      route_guide_pb2.RouteNote.SerializeToString,
    ),
  }
  return early_adopter_implementations.server("routeguide.RouteGuide", method_service_descriptions, port, private_key=private_key, certificate_chain=certificate_chain)
Пример #2
0
def early_adopter_create_TestService_server(servicer, port, private_key=None, certificate_chain=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_service_descriptions = {
    "EmptyCall": utilities.unary_unary_service_description(
      servicer.EmptyCall,
      test.cpp.interop.empty_pb2.Empty.FromString,
      test.cpp.interop.empty_pb2.Empty.SerializeToString,
    ),
    "FullDuplexCall": utilities.stream_stream_service_description(
      servicer.FullDuplexCall,
      test.cpp.interop.messages_pb2.StreamingOutputCallRequest.FromString,
      test.cpp.interop.messages_pb2.StreamingOutputCallResponse.SerializeToString,
    ),
    "HalfDuplexCall": utilities.stream_stream_service_description(
      servicer.HalfDuplexCall,
      test.cpp.interop.messages_pb2.StreamingOutputCallRequest.FromString,
      test.cpp.interop.messages_pb2.StreamingOutputCallResponse.SerializeToString,
    ),
    "StreamingInputCall": utilities.stream_unary_service_description(
      servicer.StreamingInputCall,
      test.cpp.interop.messages_pb2.StreamingInputCallRequest.FromString,
      test.cpp.interop.messages_pb2.StreamingInputCallResponse.SerializeToString,
    ),
    "StreamingOutputCall": utilities.unary_stream_service_description(
      servicer.StreamingOutputCall,
      test.cpp.interop.messages_pb2.StreamingOutputCallRequest.FromString,
      test.cpp.interop.messages_pb2.StreamingOutputCallResponse.SerializeToString,
    ),
    "UnaryCall": utilities.unary_unary_service_description(
      servicer.UnaryCall,
      test.cpp.interop.messages_pb2.SimpleRequest.FromString,
      test.cpp.interop.messages_pb2.SimpleResponse.SerializeToString,
    ),
  }
  return implementations.server("grpc.testing.TestService", method_service_descriptions, port, private_key=private_key, certificate_chain=certificate_chain)
Пример #3
0
def early_adopter_create_RouteGuide_server(servicer,
                                           port,
                                           private_key=None,
                                           certificate_chain=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_service_descriptions = {
        "GetFeature":
        alpha_utilities.unary_unary_service_description(
            servicer.GetFeature,
            route_guide_pb2.Point.FromString,
            route_guide_pb2.Feature.SerializeToString,
        ),
        "ListFeatures":
        alpha_utilities.unary_stream_service_description(
            servicer.ListFeatures,
            route_guide_pb2.Rectangle.FromString,
            route_guide_pb2.Feature.SerializeToString,
        ),
        "RecordRoute":
        alpha_utilities.stream_unary_service_description(
            servicer.RecordRoute,
            route_guide_pb2.Point.FromString,
            route_guide_pb2.RouteSummary.SerializeToString,
        ),
        "RouteChat":
        alpha_utilities.stream_stream_service_description(
            servicer.RouteChat,
            route_guide_pb2.RouteNote.FromString,
            route_guide_pb2.RouteNote.SerializeToString,
        ),
    }
    return early_adopter_implementations.server(
        "routeguide.RouteGuide",
        method_service_descriptions,
        port,
        private_key=private_key,
        certificate_chain=certificate_chain)
Пример #4
0
    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),
}

_TIMEOUT = 3


class EarlyAdopterImplementationsTest(unittest.TestCase):
    def setUp(self):
Пример #5
0
    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)


SERVICE_NAME = 'grpc.testing.TestService'

_EMPTY_CALL_METHOD_NAME = 'EmptyCall'
Пример #6
0
    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),
}

_TIMEOUT = 3


class EarlyAdopterImplementationsTest(unittest.TestCase):

  def setUp(self):
    self.server = implementations.server(
        SERVICE_NAME, _SERVICE_DESCRIPTIONS, 0)
Пример #7
0
def early_adopter_create_TestService_server(servicer,
                                            port,
                                            private_key=None,
                                            certificate_chain=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_service_descriptions = {
        "EmptyCall":
        utilities.unary_unary_service_description(
            servicer.EmptyCall,
            test.cpp.interop.empty_pb2.Empty.FromString,
            test.cpp.interop.empty_pb2.Empty.SerializeToString,
        ),
        "FullDuplexCall":
        utilities.stream_stream_service_description(
            servicer.FullDuplexCall,
            test.cpp.interop.messages_pb2.StreamingOutputCallRequest.
            FromString,
            test.cpp.interop.messages_pb2.StreamingOutputCallResponse.
            SerializeToString,
        ),
        "HalfDuplexCall":
        utilities.stream_stream_service_description(
            servicer.HalfDuplexCall,
            test.cpp.interop.messages_pb2.StreamingOutputCallRequest.
            FromString,
            test.cpp.interop.messages_pb2.StreamingOutputCallResponse.
            SerializeToString,
        ),
        "StreamingInputCall":
        utilities.stream_unary_service_description(
            servicer.StreamingInputCall,
            test.cpp.interop.messages_pb2.StreamingInputCallRequest.FromString,
            test.cpp.interop.messages_pb2.StreamingInputCallResponse.
            SerializeToString,
        ),
        "StreamingOutputCall":
        utilities.unary_stream_service_description(
            servicer.StreamingOutputCall,
            test.cpp.interop.messages_pb2.StreamingOutputCallRequest.
            FromString,
            test.cpp.interop.messages_pb2.StreamingOutputCallResponse.
            SerializeToString,
        ),
        "UnaryCall":
        utilities.unary_unary_service_description(
            servicer.UnaryCall,
            test.cpp.interop.messages_pb2.SimpleRequest.FromString,
            test.cpp.interop.messages_pb2.SimpleResponse.SerializeToString,
        ),
    }
    return implementations.server("grpc.testing.TestService",
                                  method_service_descriptions,
                                  port,
                                  private_key=private_key,
                                  certificate_chain=certificate_chain)