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)
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)
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)
def early_adopter_create_ZfsRpc_server(servicer, port, private_key=None, certificate_chain=None): import zfs_pb2 import zfs_pb2 import zfs_pb2 import zfs_pb2 import zfs_pb2 import zfs_pb2 import zfs_pb2 import zfs_pb2 import zfs_pb2 import zfs_pb2 import zfs_pb2 import zfs_pb2 import zfs_pb2 import zfs_pb2 import zfs_pb2 import zfs_pb2 import zfs_pb2 import zfs_pb2 import zfs_pb2 import zfs_pb2 import zfs_pb2 import zfs_pb2 method_service_descriptions = { "CreateFile": alpha_utilities.unary_unary_service_description( servicer.CreateFile, zfs_pb2.FilePath.FromString, zfs_pb2.StdReply.SerializeToString, ), "Fetch": alpha_utilities.unary_stream_service_description( servicer.Fetch, zfs_pb2.FilePath.FromString, zfs_pb2.FileDataBlock.SerializeToString, ), "FetchDir": alpha_utilities.unary_stream_service_description( servicer.FetchDir, zfs_pb2.FilePath.FromString, zfs_pb2.DirListBlock.SerializeToString, ), "GetFileStat": alpha_utilities.unary_unary_service_description( servicer.GetFileStat, zfs_pb2.FilePath.FromString, zfs_pb2.FileStat.SerializeToString, ), "MakeDir": alpha_utilities.unary_unary_service_description( servicer.MakeDir, zfs_pb2.FilePath.FromString, zfs_pb2.StdReply.SerializeToString, ), "RemoveDir": alpha_utilities.unary_unary_service_description( servicer.RemoveDir, zfs_pb2.FilePath.FromString, zfs_pb2.StdReply.SerializeToString, ), "RemoveFile": alpha_utilities.unary_unary_service_description( servicer.RemoveFile, zfs_pb2.FilePath.FromString, zfs_pb2.StdReply.SerializeToString, ), "Rename": alpha_utilities.unary_unary_service_description( servicer.Rename, zfs_pb2.RenameMsg.FromString, zfs_pb2.StdReply.SerializeToString, ), "SetFileStat": alpha_utilities.unary_unary_service_description( servicer.SetFileStat, zfs_pb2.FileStat.FromString, zfs_pb2.StdReply.SerializeToString, ), "Store": alpha_utilities.stream_unary_service_description( servicer.Store, zfs_pb2.FileDataBlock.FromString, zfs_pb2.StdReply.SerializeToString, ), "TestAuth": alpha_utilities.unary_unary_service_description( servicer.TestAuth, zfs_pb2.TestAuthRequest.FromString, zfs_pb2.TestAuthReply.SerializeToString, ), } return early_adopter_implementations.server("zfs.ZfsRpc", method_service_descriptions, port, private_key=private_key, certificate_chain=certificate_chain)
_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) self.server.start() port = self.server.port() self.stub = implementations.stub(SERVICE_NAME, _INVOCATION_DESCRIPTIONS, 'localhost', port)
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) _CLIENT_STREAMING_INPUT_CALL = utilities.stream_unary_invocation_description( messages_pb2.StreamingInputCallRequest.SerializeToString, 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,
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) self.server.start() port = self.server.port() self.stub = implementations.stub( SERVICE_NAME, _INVOCATION_DESCRIPTIONS, 'localhost', port)
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)