Python grpc 模块,stream_unary_rpc_method_handler() 实例源码

我们从Python开源项目中,提取了以下14个代码示例,用于说明如何使用grpc.stream_unary_rpc_method_handler()

项目:grpc-resolver    作者:justdoit0823    | 项目源码 | 文件源码
def add_HelloServicer_to_server(servicer, server):
  rpc_method_handlers = {
      'Greeter': grpc.unary_unary_rpc_method_handler(
          servicer.Greeter,
          request_deserializer=hello__pb2.HelloRequest.FromString,
          response_serializer=hello__pb2.HelloResponse.SerializeToString,
      ),
      'GreeterResponseStream': grpc.unary_stream_rpc_method_handler(
          servicer.GreeterResponseStream,
          request_deserializer=hello__pb2.HelloRequest.FromString,
          response_serializer=hello__pb2.HelloResponse.SerializeToString,
      ),
      'StreamGreeter': grpc.stream_unary_rpc_method_handler(
          servicer.StreamGreeter,
          request_deserializer=hello__pb2.HelloRequest.FromString,
          response_serializer=hello__pb2.HelloResponse.SerializeToString,
      ),
      'StreamGreeterResponseStream': grpc.stream_stream_rpc_method_handler(
          servicer.StreamGreeterResponseStream,
          request_deserializer=hello__pb2.HelloRequest.FromString,
          response_serializer=hello__pb2.HelloResponse.SerializeToString,
      ),
  }
  generic_handler = grpc.method_handlers_generic_handler(
      'grpcresolver.hello.Hello', rpc_method_handlers)
  server.add_generic_rpc_handlers((generic_handler,))
项目:grpc-resolver    作者:justdoit0823    | 项目源码 | 文件源码
def add_HelloServicer_to_server(servicer, server):
    rpc_method_handlers = {
        'Greeter': grpc.unary_unary_rpc_method_handler(
            servicer.Greeter,
            request_deserializer=HelloRequest.FromString,
            response_serializer=HelloResponse.SerializeToString,
        ),
        'GreeterResponseStream': grpc.unary_stream_rpc_method_handler(
            servicer.GreeterResponseStream,
            request_deserializer=HelloRequest.FromString,
            response_serializer=HelloResponse.SerializeToString,
        ),
        'StreamGreeter': grpc.stream_unary_rpc_method_handler(
            servicer.StreamGreeter,
            request_deserializer=HelloRequest.FromString,
            response_serializer=HelloResponse.SerializeToString,
        ),
        'StreamGreeterResponseStream': grpc.stream_stream_rpc_method_handler(
            servicer.StreamGreeterResponseStream,
            request_deserializer=HelloRequest.FromString,
            response_serializer=HelloResponse.SerializeToString,
        ),
    }
    generic_handler = grpc.method_handlers_generic_handler(
        'grpcresolver.hello.Hello', rpc_method_handlers)
    server.add_generic_rpc_handlers((generic_handler,))
项目:aquests    作者:hansroh    | 项目源码 | 文件源码
def add_RouteGuideServicer_to_server(servicer, server):
    rpc_method_handlers = {
        'GetFeature': grpc.unary_unary_rpc_method_handler(
            servicer.GetFeature,
            request_deserializer=Point.FromString,
            response_serializer=Feature.SerializeToString,
        ),
        'ListFeatures': grpc.unary_stream_rpc_method_handler(
            servicer.ListFeatures,
            request_deserializer=Rectangle.FromString,
            response_serializer=Feature.SerializeToString,
        ),
        'RecordRoute': grpc.stream_unary_rpc_method_handler(
            servicer.RecordRoute,
            request_deserializer=Point.FromString,
            response_serializer=RouteSummary.SerializeToString,
        ),
        'RouteChat': grpc.stream_stream_rpc_method_handler(
            servicer.RouteChat,
            request_deserializer=RouteNote.FromString,
            response_serializer=RouteNote.SerializeToString,
        ),
    }
    generic_handler = grpc.method_handlers_generic_handler(
        'routeguide.RouteGuide', rpc_method_handlers)
    server.add_generic_rpc_handlers((generic_handler,))
项目:ngraph    作者:NervanaSystems    | 项目源码 | 文件源码
def add_HetrServicer_to_server(servicer, server):
    rpc_method_handlers = {
        'BuildTransformer': grpc.unary_unary_rpc_method_handler(
            servicer.BuildTransformer,
            request_deserializer=BuildTransformerRequest.FromString,
            response_serializer=BuildTransformerReply.SerializeToString,
        ),
        'CloseTransformer': grpc.unary_unary_rpc_method_handler(
            servicer.CloseTransformer,
            request_deserializer=CloseTransformerRequest.FromString,
            response_serializer=CloseTransformerReply.SerializeToString,
        ),
        'Computation': grpc.stream_unary_rpc_method_handler(
            servicer.Computation,
            request_deserializer=ComputationRequest.FromString,
            response_serializer=ComputationReply.SerializeToString,
        ),
        'FeedInput': grpc.unary_unary_rpc_method_handler(
            servicer.FeedInput,
            request_deserializer=FeedInputRequest.FromString,
            response_serializer=FeedInputReply.SerializeToString,
        ),
        'GetResults': grpc.unary_unary_rpc_method_handler(
            servicer.GetResults,
            request_deserializer=GetResultsRequest.FromString,
            response_serializer=GetResultsReply.SerializeToString,
        ),
        'Close': grpc.unary_unary_rpc_method_handler(
            servicer.Close,
            request_deserializer=CloseRequest.FromString,
            response_serializer=CloseReply.SerializeToString,
        ),
    }
    generic_handler = grpc.method_handlers_generic_handler(
        'Hetr', rpc_method_handlers)
    server.add_generic_rpc_handlers((generic_handler,))
项目:ngraph    作者:NervanaSystems    | 项目源码 | 文件源码
def add_HetrServicer_to_server(servicer, server):
  rpc_method_handlers = {
      'BuildTransformer': grpc.unary_unary_rpc_method_handler(
          servicer.BuildTransformer,
          request_deserializer=ngraph_dot_transformers_dot_hetr_dot_hetr__pb2.BuildTransformerRequest.FromString,
          response_serializer=ngraph_dot_transformers_dot_hetr_dot_hetr__pb2.BuildTransformerReply.SerializeToString,
      ),
      'CloseTransformer': grpc.unary_unary_rpc_method_handler(
          servicer.CloseTransformer,
          request_deserializer=ngraph_dot_transformers_dot_hetr_dot_hetr__pb2.CloseTransformerRequest.FromString,
          response_serializer=ngraph_dot_transformers_dot_hetr_dot_hetr__pb2.CloseTransformerReply.SerializeToString,
      ),
      'Computation': grpc.stream_unary_rpc_method_handler(
          servicer.Computation,
          request_deserializer=ngraph_dot_transformers_dot_hetr_dot_hetr__pb2.ComputationRequest.FromString,
          response_serializer=ngraph_dot_transformers_dot_hetr_dot_hetr__pb2.ComputationReply.SerializeToString,
      ),
      'FeedInput': grpc.unary_unary_rpc_method_handler(
          servicer.FeedInput,
          request_deserializer=ngraph_dot_transformers_dot_hetr_dot_hetr__pb2.FeedInputRequest.FromString,
          response_serializer=ngraph_dot_transformers_dot_hetr_dot_hetr__pb2.FeedInputReply.SerializeToString,
      ),
      'GetResults': grpc.unary_unary_rpc_method_handler(
          servicer.GetResults,
          request_deserializer=ngraph_dot_transformers_dot_hetr_dot_hetr__pb2.GetResultsRequest.FromString,
          response_serializer=ngraph_dot_transformers_dot_hetr_dot_hetr__pb2.GetResultsReply.SerializeToString,
      ),
      'Close': grpc.unary_unary_rpc_method_handler(
          servicer.Close,
          request_deserializer=ngraph_dot_transformers_dot_hetr_dot_hetr__pb2.CloseRequest.FromString,
          response_serializer=ngraph_dot_transformers_dot_hetr_dot_hetr__pb2.CloseReply.SerializeToString,
      ),
  }
  generic_handler = grpc.method_handlers_generic_handler(
      'Hetr', rpc_method_handlers)
  server.add_generic_rpc_handlers((generic_handler,))
项目:relaax    作者:deeplearninc    | 项目源码 | 文件源码
def add_BridgeServicer_to_server(servicer, server):
    rpc_method_handlers = {
        'Init': grpc.unary_unary_rpc_method_handler(
            servicer.Init,
            request_deserializer=NullMessage.FromString,
            response_serializer=NullMessage.SerializeToString,
        ),
        'Run': grpc.stream_stream_rpc_method_handler(
            servicer.Run,
            request_deserializer=Item.FromString,
            response_serializer=Item.SerializeToString,
        ),
        'SetX': grpc.unary_unary_rpc_method_handler(
            servicer.SetX,
            request_deserializer=X.FromString,
            response_serializer=NullMessage.SerializeToString,
        ),
        'StoreMetric': grpc.stream_unary_rpc_method_handler(
            servicer.StoreMetric,
            request_deserializer=Item.FromString,
            response_serializer=NullMessage.SerializeToString,
        ),
    }
    generic_handler = grpc.method_handlers_generic_handler(
        'Bridge', rpc_method_handlers)
    server.add_generic_rpc_handlers((generic_handler,))
项目:relaax    作者:deeplearninc    | 项目源码 | 文件源码
def add_BridgeServicer_to_server(servicer, server):
  rpc_method_handlers = {
      'Init': grpc.unary_unary_rpc_method_handler(
          servicer.Init,
          request_deserializer=bridge__pb2.NullMessage.FromString,
          response_serializer=bridge__pb2.NullMessage.SerializeToString,
      ),
      'Run': grpc.stream_stream_rpc_method_handler(
          servicer.Run,
          request_deserializer=bridge__pb2.Item.FromString,
          response_serializer=bridge__pb2.Item.SerializeToString,
      ),
      'SetX': grpc.unary_unary_rpc_method_handler(
          servicer.SetX,
          request_deserializer=bridge__pb2.X.FromString,
          response_serializer=bridge__pb2.NullMessage.SerializeToString,
      ),
      'StoreMetric': grpc.stream_unary_rpc_method_handler(
          servicer.StoreMetric,
          request_deserializer=bridge__pb2.Item.FromString,
          response_serializer=bridge__pb2.NullMessage.SerializeToString,
      ),
  }
  generic_handler = grpc.method_handlers_generic_handler(
      'Bridge', rpc_method_handlers)
  server.add_generic_rpc_handlers((generic_handler,))
项目:grpc-opentracing    作者:grpc-ecosystem    | 项目源码 | 文件源码
def add_StoreServicer_to_server(servicer, server):
    rpc_method_handlers = {
        'AddItem': grpc.unary_unary_rpc_method_handler(
            servicer.AddItem,
            request_deserializer=AddItemRequest.FromString,
            response_serializer=Empty.SerializeToString,
        ),
        'AddItems': grpc.stream_unary_rpc_method_handler(
            servicer.AddItems,
            request_deserializer=AddItemRequest.FromString,
            response_serializer=Empty.SerializeToString,
        ),
        'RemoveItem': grpc.unary_unary_rpc_method_handler(
            servicer.RemoveItem,
            request_deserializer=RemoveItemRequest.FromString,
            response_serializer=RemoveItemResponse.SerializeToString,
        ),
        'RemoveItems': grpc.stream_unary_rpc_method_handler(
            servicer.RemoveItems,
            request_deserializer=RemoveItemRequest.FromString,
            response_serializer=RemoveItemResponse.SerializeToString,
        ),
        'ListInventory': grpc.unary_stream_rpc_method_handler(
            servicer.ListInventory,
            request_deserializer=Empty.FromString,
            response_serializer=QuantityResponse.SerializeToString,
        ),
        'QueryQuantity': grpc.unary_unary_rpc_method_handler(
            servicer.QueryQuantity,
            request_deserializer=QueryItemRequest.FromString,
            response_serializer=QuantityResponse.SerializeToString,
        ),
        'QueryQuantities': grpc.stream_stream_rpc_method_handler(
            servicer.QueryQuantities,
            request_deserializer=QueryItemRequest.FromString,
            response_serializer=QuantityResponse.SerializeToString,
        ),
    }
    generic_handler = grpc.method_handlers_generic_handler(
        'store.Store', rpc_method_handlers)
    server.add_generic_rpc_handlers((generic_handler,))
项目:grpc-opentracing    作者:grpc-ecosystem    | 项目源码 | 文件源码
def add_StoreServicer_to_server(servicer, server):
  rpc_method_handlers = {
      'AddItem': grpc.unary_unary_rpc_method_handler(
          servicer.AddItem,
          request_deserializer=store__pb2.AddItemRequest.FromString,
          response_serializer=store__pb2.Empty.SerializeToString,
      ),
      'AddItems': grpc.stream_unary_rpc_method_handler(
          servicer.AddItems,
          request_deserializer=store__pb2.AddItemRequest.FromString,
          response_serializer=store__pb2.Empty.SerializeToString,
      ),
      'RemoveItem': grpc.unary_unary_rpc_method_handler(
          servicer.RemoveItem,
          request_deserializer=store__pb2.RemoveItemRequest.FromString,
          response_serializer=store__pb2.RemoveItemResponse.SerializeToString,
      ),
      'RemoveItems': grpc.stream_unary_rpc_method_handler(
          servicer.RemoveItems,
          request_deserializer=store__pb2.RemoveItemRequest.FromString,
          response_serializer=store__pb2.RemoveItemResponse.SerializeToString,
      ),
      'ListInventory': grpc.unary_stream_rpc_method_handler(
          servicer.ListInventory,
          request_deserializer=store__pb2.Empty.FromString,
          response_serializer=store__pb2.QuantityResponse.SerializeToString,
      ),
      'QueryQuantity': grpc.unary_unary_rpc_method_handler(
          servicer.QueryQuantity,
          request_deserializer=store__pb2.QueryItemRequest.FromString,
          response_serializer=store__pb2.QuantityResponse.SerializeToString,
      ),
      'QueryQuantities': grpc.stream_stream_rpc_method_handler(
          servicer.QueryQuantities,
          request_deserializer=store__pb2.QueryItemRequest.FromString,
          response_serializer=store__pb2.QuantityResponse.SerializeToString,
      ),
  }
  generic_handler = grpc.method_handlers_generic_handler(
      'store.Store', rpc_method_handlers)
  server.add_generic_rpc_handlers((generic_handler,))
项目:quant    作者:yutiansut    | 项目源码 | 文件源码
def add_RouteGuideServicer_to_server(servicer, server):
    rpc_method_handlers = {
        'GetFeature': grpc.unary_unary_rpc_method_handler(
            servicer.GetFeature,
            request_deserializer=Point.FromString,
            response_serializer=Feature.SerializeToString,
        ),
        'ListFeatures': grpc.unary_stream_rpc_method_handler(
            servicer.ListFeatures,
            request_deserializer=Rectangle.FromString,
            response_serializer=Feature.SerializeToString,
        ),
        'RecordRoute': grpc.stream_unary_rpc_method_handler(
            servicer.RecordRoute,
            request_deserializer=Point.FromString,
            response_serializer=RouteSummary.SerializeToString,
        ),
        'RouteChat': grpc.stream_stream_rpc_method_handler(
            servicer.RouteChat,
            request_deserializer=RouteNote.FromString,
            response_serializer=RouteNote.SerializeToString,
        ),
    }
    generic_handler = grpc.method_handlers_generic_handler(
        'routeguide.RouteGuide', rpc_method_handlers)
    server.add_generic_rpc_handlers((generic_handler,))
项目:quant    作者:yutiansut    | 项目源码 | 文件源码
def add_RouteGuideServicer_to_server(servicer, server):
  rpc_method_handlers = {
      'GetFeature': grpc.unary_unary_rpc_method_handler(
          servicer.GetFeature,
          request_deserializer=route__guide__pb2.Point.FromString,
          response_serializer=route__guide__pb2.Feature.SerializeToString,
      ),
      'ListFeatures': grpc.unary_stream_rpc_method_handler(
          servicer.ListFeatures,
          request_deserializer=route__guide__pb2.Rectangle.FromString,
          response_serializer=route__guide__pb2.Feature.SerializeToString,
      ),
      'RecordRoute': grpc.stream_unary_rpc_method_handler(
          servicer.RecordRoute,
          request_deserializer=route__guide__pb2.Point.FromString,
          response_serializer=route__guide__pb2.RouteSummary.SerializeToString,
      ),
      'RouteChat': grpc.stream_stream_rpc_method_handler(
          servicer.RouteChat,
          request_deserializer=route__guide__pb2.RouteNote.FromString,
          response_serializer=route__guide__pb2.RouteNote.SerializeToString,
      ),
  }
  generic_handler = grpc.method_handlers_generic_handler(
      'routeguide.RouteGuide', rpc_method_handlers)
  server.add_generic_rpc_handlers((generic_handler,))
项目:skynet    作者:skynetera    | 项目源码 | 文件源码
def add_RouteGuideServicer_to_server(servicer, server):
  rpc_method_handlers = {
      'GetFeature': grpc.unary_unary_rpc_method_handler(
          servicer.GetFeature,
          request_deserializer=Point.FromString,
          response_serializer=Feature.SerializeToString,
      ),
      'ListFeatures': grpc.unary_stream_rpc_method_handler(
          servicer.ListFeatures,
          request_deserializer=Rectangle.FromString,
          response_serializer=Feature.SerializeToString,
      ),
      'RecordRoute': grpc.stream_unary_rpc_method_handler(
          servicer.RecordRoute,
          request_deserializer=Point.FromString,
          response_serializer=RouteSummary.SerializeToString,
      ),
      'RouteChat': grpc.stream_stream_rpc_method_handler(
          servicer.RouteChat,
          request_deserializer=RouteNote.FromString,
          response_serializer=RouteNote.SerializeToString,
      ),
  }
  generic_handler = grpc.method_handlers_generic_handler(
      'routeguide.RouteGuide', rpc_method_handlers)
  server.add_generic_rpc_handlers((generic_handler,))
项目:aiogrpc    作者:hubo1016    | 项目源码 | 文件源码
def add_TestServiceServicer_to_server(servicer, server):
  rpc_method_handlers = {
      'NormalMethod': grpc.unary_unary_rpc_method_handler(
          servicer.NormalMethod,
          request_deserializer=service__pb2.StandardRequest.FromString,
          response_serializer=service__pb2.StandardReply.SerializeToString,
      ),
      'StreamMethod': grpc.unary_stream_rpc_method_handler(
          servicer.StreamMethod,
          request_deserializer=service__pb2.StreamRequest.FromString,
          response_serializer=service__pb2.StandardReply.SerializeToString,
      ),
      'StreamInputMethod': grpc.stream_unary_rpc_method_handler(
          servicer.StreamInputMethod,
          request_deserializer=service__pb2.StandardRequest.FromString,
          response_serializer=service__pb2.StreamReply.SerializeToString,
      ),
      'StreamStreamMethod': grpc.stream_stream_rpc_method_handler(
          servicer.StreamStreamMethod,
          request_deserializer=service__pb2.StandardRequest.FromString,
          response_serializer=service__pb2.StandardReply.SerializeToString,
      ),
      'DelayedMethod': grpc.unary_unary_rpc_method_handler(
          servicer.DelayedMethod,
          request_deserializer=service__pb2.StandardRequest.FromString,
          response_serializer=service__pb2.StandardReply.SerializeToString,
      ),
      'ExceptionMethod': grpc.unary_unary_rpc_method_handler(
          servicer.ExceptionMethod,
          request_deserializer=service__pb2.StandardRequest.FromString,
          response_serializer=service__pb2.StandardReply.SerializeToString,
      ),
      'DelayedStream': grpc.unary_stream_rpc_method_handler(
          servicer.DelayedStream,
          request_deserializer=service__pb2.StreamRequest.FromString,
          response_serializer=service__pb2.StandardReply.SerializeToString,
      ),
  }
  generic_handler = grpc.method_handlers_generic_handler(
      'TestService', rpc_method_handlers)
  server.add_generic_rpc_handlers((generic_handler,))
项目:aiogrpc    作者:hubo1016    | 项目源码 | 文件源码
def add_TestServiceServicer_to_server(servicer, server):
    rpc_method_handlers = {
        'NormalMethod': grpc.unary_unary_rpc_method_handler(
            servicer.NormalMethod,
            request_deserializer=StandardRequest.FromString,
            response_serializer=StandardReply.SerializeToString,
        ),
        'StreamMethod': grpc.unary_stream_rpc_method_handler(
            servicer.StreamMethod,
            request_deserializer=StreamRequest.FromString,
            response_serializer=StandardReply.SerializeToString,
        ),
        'StreamInputMethod': grpc.stream_unary_rpc_method_handler(
            servicer.StreamInputMethod,
            request_deserializer=StandardRequest.FromString,
            response_serializer=StreamReply.SerializeToString,
        ),
        'StreamStreamMethod': grpc.stream_stream_rpc_method_handler(
            servicer.StreamStreamMethod,
            request_deserializer=StandardRequest.FromString,
            response_serializer=StandardReply.SerializeToString,
        ),
        'DelayedMethod': grpc.unary_unary_rpc_method_handler(
            servicer.DelayedMethod,
            request_deserializer=StandardRequest.FromString,
            response_serializer=StandardReply.SerializeToString,
        ),
        'ExceptionMethod': grpc.unary_unary_rpc_method_handler(
            servicer.ExceptionMethod,
            request_deserializer=StandardRequest.FromString,
            response_serializer=StandardReply.SerializeToString,
        ),
        'DelayedStream': grpc.unary_stream_rpc_method_handler(
            servicer.DelayedStream,
            request_deserializer=StreamRequest.FromString,
            response_serializer=StandardReply.SerializeToString,
        ),
    }
    generic_handler = grpc.method_handlers_generic_handler(
        'TestService', rpc_method_handlers)
    server.add_generic_rpc_handlers((generic_handler,))