parent
c128e61cf4
commit
a362c2566d
78 changed files with 2243 additions and 897 deletions
@ -1,38 +0,0 @@ |
||||
// Copyright 2015 gRPC authors. |
||||
// |
||||
// Licensed under the Apache License, Version 2.0 (the "License"); |
||||
// you may not use this file except in compliance with the License. |
||||
// You may obtain a copy of the License at |
||||
// |
||||
// http://www.apache.org/licenses/LICENSE-2.0 |
||||
// |
||||
// Unless required by applicable law or agreed to in writing, software |
||||
// distributed under the License is distributed on an "AS IS" BASIS, |
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
// See the License for the specific language governing permissions and |
||||
// limitations under the License. |
||||
|
||||
syntax = "proto3"; |
||||
|
||||
option java_multiple_files = true; |
||||
option java_package = "io.grpc.examples.helloworld"; |
||||
option java_outer_classname = "HelloWorldProto"; |
||||
option objc_class_prefix = "HLW"; |
||||
|
||||
package helloworld; |
||||
|
||||
// The greeting service definition. |
||||
service Greeter { |
||||
// Sends a greeting |
||||
rpc SayHello (HelloRequest) returns (HelloReply) {} |
||||
} |
||||
|
||||
// The request message containing the user's name. |
||||
message HelloRequest { |
||||
string name = 1; |
||||
} |
||||
|
||||
// The response message containing the greetings |
||||
message HelloReply { |
||||
string message = 1; |
||||
} |
@ -0,0 +1,174 @@ |
||||
# -*- coding: utf-8 -*- |
||||
# Generated by the protocol buffer compiler. DO NOT EDIT! |
||||
# source: demo.proto |
||||
|
||||
import sys |
||||
_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1')) |
||||
from google.protobuf import descriptor as _descriptor |
||||
from google.protobuf import message as _message |
||||
from google.protobuf import reflection as _reflection |
||||
from google.protobuf import symbol_database as _symbol_database |
||||
# @@protoc_insertion_point(imports) |
||||
|
||||
_sym_db = _symbol_database.Default() |
||||
|
||||
|
||||
|
||||
|
||||
DESCRIPTOR = _descriptor.FileDescriptor( |
||||
name='demo.proto', |
||||
package='demo', |
||||
syntax='proto3', |
||||
serialized_options=None, |
||||
serialized_pb=_b('\n\ndemo.proto\x12\x04\x64\x65mo\"2\n\x07Request\x12\x11\n\tclient_id\x18\x01 \x01(\x03\x12\x14\n\x0crequest_data\x18\x02 \x01(\t\"4\n\x08Response\x12\x11\n\tserver_id\x18\x01 \x01(\x03\x12\x15\n\rresponse_data\x18\x02 \x01(\t2\xf0\x01\n\x08GRPCDemo\x12-\n\x0cSimpleMethod\x12\r.demo.Request\x1a\x0e.demo.Response\x12\x38\n\x15\x43lientStreamingMethod\x12\r.demo.Request\x1a\x0e.demo.Response(\x01\x12\x38\n\x15ServerStreamingMethod\x12\r.demo.Request\x1a\x0e.demo.Response0\x01\x12\x41\n\x1c\x42idirectionalStreamingMethod\x12\r.demo.Request\x1a\x0e.demo.Response(\x01\x30\x01\x62\x06proto3') |
||||
) |
||||
|
||||
|
||||
|
||||
|
||||
_REQUEST = _descriptor.Descriptor( |
||||
name='Request', |
||||
full_name='demo.Request', |
||||
filename=None, |
||||
file=DESCRIPTOR, |
||||
containing_type=None, |
||||
fields=[ |
||||
_descriptor.FieldDescriptor( |
||||
name='client_id', full_name='demo.Request.client_id', index=0, |
||||
number=1, type=3, cpp_type=2, label=1, |
||||
has_default_value=False, default_value=0, |
||||
message_type=None, enum_type=None, containing_type=None, |
||||
is_extension=False, extension_scope=None, |
||||
serialized_options=None, file=DESCRIPTOR), |
||||
_descriptor.FieldDescriptor( |
||||
name='request_data', full_name='demo.Request.request_data', index=1, |
||||
number=2, type=9, cpp_type=9, label=1, |
||||
has_default_value=False, default_value=_b("").decode('utf-8'), |
||||
message_type=None, enum_type=None, containing_type=None, |
||||
is_extension=False, extension_scope=None, |
||||
serialized_options=None, file=DESCRIPTOR), |
||||
], |
||||
extensions=[ |
||||
], |
||||
nested_types=[], |
||||
enum_types=[ |
||||
], |
||||
serialized_options=None, |
||||
is_extendable=False, |
||||
syntax='proto3', |
||||
extension_ranges=[], |
||||
oneofs=[ |
||||
], |
||||
serialized_start=20, |
||||
serialized_end=70, |
||||
) |
||||
|
||||
|
||||
_RESPONSE = _descriptor.Descriptor( |
||||
name='Response', |
||||
full_name='demo.Response', |
||||
filename=None, |
||||
file=DESCRIPTOR, |
||||
containing_type=None, |
||||
fields=[ |
||||
_descriptor.FieldDescriptor( |
||||
name='server_id', full_name='demo.Response.server_id', index=0, |
||||
number=1, type=3, cpp_type=2, label=1, |
||||
has_default_value=False, default_value=0, |
||||
message_type=None, enum_type=None, containing_type=None, |
||||
is_extension=False, extension_scope=None, |
||||
serialized_options=None, file=DESCRIPTOR), |
||||
_descriptor.FieldDescriptor( |
||||
name='response_data', full_name='demo.Response.response_data', index=1, |
||||
number=2, type=9, cpp_type=9, label=1, |
||||
has_default_value=False, default_value=_b("").decode('utf-8'), |
||||
message_type=None, enum_type=None, containing_type=None, |
||||
is_extension=False, extension_scope=None, |
||||
serialized_options=None, file=DESCRIPTOR), |
||||
], |
||||
extensions=[ |
||||
], |
||||
nested_types=[], |
||||
enum_types=[ |
||||
], |
||||
serialized_options=None, |
||||
is_extendable=False, |
||||
syntax='proto3', |
||||
extension_ranges=[], |
||||
oneofs=[ |
||||
], |
||||
serialized_start=72, |
||||
serialized_end=124, |
||||
) |
||||
|
||||
DESCRIPTOR.message_types_by_name['Request'] = _REQUEST |
||||
DESCRIPTOR.message_types_by_name['Response'] = _RESPONSE |
||||
_sym_db.RegisterFileDescriptor(DESCRIPTOR) |
||||
|
||||
Request = _reflection.GeneratedProtocolMessageType('Request', (_message.Message,), { |
||||
'DESCRIPTOR' : _REQUEST, |
||||
'__module__' : 'demo_pb2' |
||||
# @@protoc_insertion_point(class_scope:demo.Request) |
||||
}) |
||||
_sym_db.RegisterMessage(Request) |
||||
|
||||
Response = _reflection.GeneratedProtocolMessageType('Response', (_message.Message,), { |
||||
'DESCRIPTOR' : _RESPONSE, |
||||
'__module__' : 'demo_pb2' |
||||
# @@protoc_insertion_point(class_scope:demo.Response) |
||||
}) |
||||
_sym_db.RegisterMessage(Response) |
||||
|
||||
|
||||
|
||||
_GRPCDEMO = _descriptor.ServiceDescriptor( |
||||
name='GRPCDemo', |
||||
full_name='demo.GRPCDemo', |
||||
file=DESCRIPTOR, |
||||
index=0, |
||||
serialized_options=None, |
||||
serialized_start=127, |
||||
serialized_end=367, |
||||
methods=[ |
||||
_descriptor.MethodDescriptor( |
||||
name='SimpleMethod', |
||||
full_name='demo.GRPCDemo.SimpleMethod', |
||||
index=0, |
||||
containing_service=None, |
||||
input_type=_REQUEST, |
||||
output_type=_RESPONSE, |
||||
serialized_options=None, |
||||
), |
||||
_descriptor.MethodDescriptor( |
||||
name='ClientStreamingMethod', |
||||
full_name='demo.GRPCDemo.ClientStreamingMethod', |
||||
index=1, |
||||
containing_service=None, |
||||
input_type=_REQUEST, |
||||
output_type=_RESPONSE, |
||||
serialized_options=None, |
||||
), |
||||
_descriptor.MethodDescriptor( |
||||
name='ServerStreamingMethod', |
||||
full_name='demo.GRPCDemo.ServerStreamingMethod', |
||||
index=2, |
||||
containing_service=None, |
||||
input_type=_REQUEST, |
||||
output_type=_RESPONSE, |
||||
serialized_options=None, |
||||
), |
||||
_descriptor.MethodDescriptor( |
||||
name='BidirectionalStreamingMethod', |
||||
full_name='demo.GRPCDemo.BidirectionalStreamingMethod', |
||||
index=3, |
||||
containing_service=None, |
||||
input_type=_REQUEST, |
||||
output_type=_RESPONSE, |
||||
serialized_options=None, |
||||
), |
||||
]) |
||||
_sym_db.RegisterServiceDescriptor(_GRPCDEMO) |
||||
|
||||
DESCRIPTOR.services_by_name['GRPCDemo'] = _GRPCDEMO |
||||
|
||||
# @@protoc_insertion_point(module_scope) |
@ -0,0 +1,106 @@ |
||||
# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! |
||||
import grpc |
||||
|
||||
import demo_pb2 as demo__pb2 |
||||
|
||||
|
||||
class GRPCDemoStub(object): |
||||
"""service是用来给GRPC服务定义方法的, 格式固定, 类似于Golang中定义一个接口 |
||||
`service` is used to define methods for GRPC services in a fixed format, similar to defining an interface in Golang |
||||
""" |
||||
|
||||
def __init__(self, channel): |
||||
"""Constructor. |
||||
|
||||
Args: |
||||
channel: A grpc.Channel. |
||||
""" |
||||
self.SimpleMethod = channel.unary_unary( |
||||
'/demo.GRPCDemo/SimpleMethod', |
||||
request_serializer=demo__pb2.Request.SerializeToString, |
||||
response_deserializer=demo__pb2.Response.FromString, |
||||
) |
||||
self.ClientStreamingMethod = channel.stream_unary( |
||||
'/demo.GRPCDemo/ClientStreamingMethod', |
||||
request_serializer=demo__pb2.Request.SerializeToString, |
||||
response_deserializer=demo__pb2.Response.FromString, |
||||
) |
||||
self.ServerStreamingMethod = channel.unary_stream( |
||||
'/demo.GRPCDemo/ServerStreamingMethod', |
||||
request_serializer=demo__pb2.Request.SerializeToString, |
||||
response_deserializer=demo__pb2.Response.FromString, |
||||
) |
||||
self.BidirectionalStreamingMethod = channel.stream_stream( |
||||
'/demo.GRPCDemo/BidirectionalStreamingMethod', |
||||
request_serializer=demo__pb2.Request.SerializeToString, |
||||
response_deserializer=demo__pb2.Response.FromString, |
||||
) |
||||
|
||||
|
||||
class GRPCDemoServicer(object): |
||||
"""service是用来给GRPC服务定义方法的, 格式固定, 类似于Golang中定义一个接口 |
||||
`service` is used to define methods for GRPC services in a fixed format, similar to defining an interface in Golang |
||||
""" |
||||
|
||||
def SimpleMethod(self, request, context): |
||||
"""简单模式 |
||||
unary-unary |
||||
""" |
||||
context.set_code(grpc.StatusCode.UNIMPLEMENTED) |
||||
context.set_details('Method not implemented!') |
||||
raise NotImplementedError('Method not implemented!') |
||||
|
||||
def ClientStreamingMethod(self, request_iterator, context): |
||||
"""客户端流模式(在一次调用中, 客户端可以多次向服务器传输数据, 但是服务器只能返回一次响应) |
||||
stream-unary (In a single call, the client can transfer data to the server several times, |
||||
but the server can only return a response once.) |
||||
""" |
||||
context.set_code(grpc.StatusCode.UNIMPLEMENTED) |
||||
context.set_details('Method not implemented!') |
||||
raise NotImplementedError('Method not implemented!') |
||||
|
||||
def ServerStreamingMethod(self, request, context): |
||||
"""服务端流模式(在一次调用中, 客户端只能一次向服务器传输数据, 但是服务器可以多次返回响应) |
||||
unary-stream (In a single call, the client can only transmit data to the server at one time, |
||||
but the server can return the response many times.) |
||||
""" |
||||
context.set_code(grpc.StatusCode.UNIMPLEMENTED) |
||||
context.set_details('Method not implemented!') |
||||
raise NotImplementedError('Method not implemented!') |
||||
|
||||
def BidirectionalStreamingMethod(self, request_iterator, context): |
||||
"""双向流模式 (在一次调用中, 客户端和服务器都可以向对方多次收发数据) |
||||
stream-stream (In a single call, both client and server can send and receive data |
||||
to each other multiple times.) |
||||
""" |
||||
context.set_code(grpc.StatusCode.UNIMPLEMENTED) |
||||
context.set_details('Method not implemented!') |
||||
raise NotImplementedError('Method not implemented!') |
||||
|
||||
|
||||
def add_GRPCDemoServicer_to_server(servicer, server): |
||||
rpc_method_handlers = { |
||||
'SimpleMethod': grpc.unary_unary_rpc_method_handler( |
||||
servicer.SimpleMethod, |
||||
request_deserializer=demo__pb2.Request.FromString, |
||||
response_serializer=demo__pb2.Response.SerializeToString, |
||||
), |
||||
'ClientStreamingMethod': grpc.stream_unary_rpc_method_handler( |
||||
servicer.ClientStreamingMethod, |
||||
request_deserializer=demo__pb2.Request.FromString, |
||||
response_serializer=demo__pb2.Response.SerializeToString, |
||||
), |
||||
'ServerStreamingMethod': grpc.unary_stream_rpc_method_handler( |
||||
servicer.ServerStreamingMethod, |
||||
request_deserializer=demo__pb2.Request.FromString, |
||||
response_serializer=demo__pb2.Response.SerializeToString, |
||||
), |
||||
'BidirectionalStreamingMethod': grpc.stream_stream_rpc_method_handler( |
||||
servicer.BidirectionalStreamingMethod, |
||||
request_deserializer=demo__pb2.Request.FromString, |
||||
response_serializer=demo__pb2.Response.SerializeToString, |
||||
), |
||||
} |
||||
generic_handler = grpc.method_handlers_generic_handler( |
||||
'demo.GRPCDemo', rpc_method_handlers) |
||||
server.add_generic_rpc_handlers((generic_handler,)) |
@ -1,38 +0,0 @@ |
||||
// Copyright 2015 gRPC authors. |
||||
// |
||||
// Licensed under the Apache License, Version 2.0 (the "License"); |
||||
// you may not use this file except in compliance with the License. |
||||
// You may obtain a copy of the License at |
||||
// |
||||
// http://www.apache.org/licenses/LICENSE-2.0 |
||||
// |
||||
// Unless required by applicable law or agreed to in writing, software |
||||
// distributed under the License is distributed on an "AS IS" BASIS, |
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
// See the License for the specific language governing permissions and |
||||
// limitations under the License. |
||||
|
||||
syntax = "proto3"; |
||||
|
||||
option java_multiple_files = true; |
||||
option java_package = "io.grpc.examples.helloworld"; |
||||
option java_outer_classname = "HelloWorldProto"; |
||||
option objc_class_prefix = "HLW"; |
||||
|
||||
package helloworld; |
||||
|
||||
// The greeting service definition. |
||||
service Greeter { |
||||
// Sends a greeting |
||||
rpc SayHello (HelloRequest) returns (HelloReply) {} |
||||
} |
||||
|
||||
// The request message containing the user's name. |
||||
message HelloRequest { |
||||
string name = 1; |
||||
} |
||||
|
||||
// The response message containing the greetings |
||||
message HelloReply { |
||||
string message = 1; |
||||
} |
@ -1,38 +0,0 @@ |
||||
// Copyright 2015 gRPC authors. |
||||
// |
||||
// Licensed under the Apache License, Version 2.0 (the "License"); |
||||
// you may not use this file except in compliance with the License. |
||||
// You may obtain a copy of the License at |
||||
// |
||||
// http://www.apache.org/licenses/LICENSE-2.0 |
||||
// |
||||
// Unless required by applicable law or agreed to in writing, software |
||||
// distributed under the License is distributed on an "AS IS" BASIS, |
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
// See the License for the specific language governing permissions and |
||||
// limitations under the License. |
||||
|
||||
syntax = "proto3"; |
||||
|
||||
option java_multiple_files = true; |
||||
option java_package = "io.grpc.examples.helloworld"; |
||||
option java_outer_classname = "HelloWorldProto"; |
||||
option objc_class_prefix = "HLW"; |
||||
|
||||
package helloworld; |
||||
|
||||
// The greeting service definition. |
||||
service Greeter { |
||||
// Sends a greeting |
||||
rpc SayHello (HelloRequest) returns (HelloReply) {} |
||||
} |
||||
|
||||
// The request message containing the user's name. |
||||
message HelloRequest { |
||||
string name = 1; |
||||
} |
||||
|
||||
// The response message containing the greetings |
||||
message HelloReply { |
||||
string message = 1; |
||||
} |
@ -1,38 +0,0 @@ |
||||
// Copyright 2015 gRPC authors. |
||||
// |
||||
// Licensed under the Apache License, Version 2.0 (the "License"); |
||||
// you may not use this file except in compliance with the License. |
||||
// You may obtain a copy of the License at |
||||
// |
||||
// http://www.apache.org/licenses/LICENSE-2.0 |
||||
// |
||||
// Unless required by applicable law or agreed to in writing, software |
||||
// distributed under the License is distributed on an "AS IS" BASIS, |
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
// See the License for the specific language governing permissions and |
||||
// limitations under the License. |
||||
|
||||
syntax = "proto3"; |
||||
|
||||
option java_multiple_files = true; |
||||
option java_package = "io.grpc.examples.helloworld"; |
||||
option java_outer_classname = "HelloWorldProto"; |
||||
option objc_class_prefix = "HLW"; |
||||
|
||||
package helloworld; |
||||
|
||||
// The greeting service definition. |
||||
service Greeter { |
||||
// Sends a greeting |
||||
rpc SayHello (HelloRequest) returns (HelloReply) {} |
||||
} |
||||
|
||||
// The request message containing the user's name. |
||||
message HelloRequest { |
||||
string name = 1; |
||||
} |
||||
|
||||
// The response message containing the greetings |
||||
message HelloReply { |
||||
string message = 1; |
||||
} |
@ -1,38 +0,0 @@ |
||||
// Copyright 2015 gRPC authors. |
||||
// |
||||
// Licensed under the Apache License, Version 2.0 (the "License"); |
||||
// you may not use this file except in compliance with the License. |
||||
// You may obtain a copy of the License at |
||||
// |
||||
// http://www.apache.org/licenses/LICENSE-2.0 |
||||
// |
||||
// Unless required by applicable law or agreed to in writing, software |
||||
// distributed under the License is distributed on an "AS IS" BASIS, |
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
// See the License for the specific language governing permissions and |
||||
// limitations under the License. |
||||
|
||||
syntax = "proto3"; |
||||
|
||||
option java_multiple_files = true; |
||||
option java_package = "io.grpc.examples.helloworld"; |
||||
option java_outer_classname = "HelloWorldProto"; |
||||
option objc_class_prefix = "HLW"; |
||||
|
||||
package helloworld; |
||||
|
||||
// The greeting service definition. |
||||
service Greeter { |
||||
// Sends a greeting |
||||
rpc SayHello (HelloRequest) returns (HelloReply) {} |
||||
} |
||||
|
||||
// The request message containing the user's name. |
||||
message HelloRequest { |
||||
string name = 1; |
||||
} |
||||
|
||||
// The response message containing the greetings |
||||
message HelloReply { |
||||
string message = 1; |
||||
} |
@ -0,0 +1,134 @@ |
||||
# Generated by the protocol buffer compiler. DO NOT EDIT! |
||||
# source: helloworld.proto |
||||
|
||||
import sys |
||||
_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1')) |
||||
from google.protobuf import descriptor as _descriptor |
||||
from google.protobuf import message as _message |
||||
from google.protobuf import reflection as _reflection |
||||
from google.protobuf import symbol_database as _symbol_database |
||||
from google.protobuf import descriptor_pb2 |
||||
# @@protoc_insertion_point(imports) |
||||
|
||||
_sym_db = _symbol_database.Default() |
||||
|
||||
|
||||
|
||||
|
||||
DESCRIPTOR = _descriptor.FileDescriptor( |
||||
name='helloworld.proto', |
||||
package='helloworld', |
||||
syntax='proto3', |
||||
serialized_pb=_b('\n\x10helloworld.proto\x12\nhelloworld\"\x1c\n\x0cHelloRequest\x12\x0c\n\x04name\x18\x01 \x01(\t\"\x1d\n\nHelloReply\x12\x0f\n\x07message\x18\x01 \x01(\t2I\n\x07Greeter\x12>\n\x08SayHello\x12\x18.helloworld.HelloRequest\x1a\x16.helloworld.HelloReply\"\x00\x42\x36\n\x1bio.grpc.examples.helloworldB\x0fHelloWorldProtoP\x01\xa2\x02\x03HLWb\x06proto3') |
||||
) |
||||
|
||||
|
||||
|
||||
|
||||
_HELLOREQUEST = _descriptor.Descriptor( |
||||
name='HelloRequest', |
||||
full_name='helloworld.HelloRequest', |
||||
filename=None, |
||||
file=DESCRIPTOR, |
||||
containing_type=None, |
||||
fields=[ |
||||
_descriptor.FieldDescriptor( |
||||
name='name', full_name='helloworld.HelloRequest.name', index=0, |
||||
number=1, type=9, cpp_type=9, label=1, |
||||
has_default_value=False, default_value=_b("").decode('utf-8'), |
||||
message_type=None, enum_type=None, containing_type=None, |
||||
is_extension=False, extension_scope=None, |
||||
options=None), |
||||
], |
||||
extensions=[ |
||||
], |
||||
nested_types=[], |
||||
enum_types=[ |
||||
], |
||||
options=None, |
||||
is_extendable=False, |
||||
syntax='proto3', |
||||
extension_ranges=[], |
||||
oneofs=[ |
||||
], |
||||
serialized_start=32, |
||||
serialized_end=60, |
||||
) |
||||
|
||||
|
||||
_HELLOREPLY = _descriptor.Descriptor( |
||||
name='HelloReply', |
||||
full_name='helloworld.HelloReply', |
||||
filename=None, |
||||
file=DESCRIPTOR, |
||||
containing_type=None, |
||||
fields=[ |
||||
_descriptor.FieldDescriptor( |
||||
name='message', full_name='helloworld.HelloReply.message', index=0, |
||||
number=1, type=9, cpp_type=9, label=1, |
||||
has_default_value=False, default_value=_b("").decode('utf-8'), |
||||
message_type=None, enum_type=None, containing_type=None, |
||||
is_extension=False, extension_scope=None, |
||||
options=None), |
||||
], |
||||
extensions=[ |
||||
], |
||||
nested_types=[], |
||||
enum_types=[ |
||||
], |
||||
options=None, |
||||
is_extendable=False, |
||||
syntax='proto3', |
||||
extension_ranges=[], |
||||
oneofs=[ |
||||
], |
||||
serialized_start=62, |
||||
serialized_end=91, |
||||
) |
||||
|
||||
DESCRIPTOR.message_types_by_name['HelloRequest'] = _HELLOREQUEST |
||||
DESCRIPTOR.message_types_by_name['HelloReply'] = _HELLOREPLY |
||||
_sym_db.RegisterFileDescriptor(DESCRIPTOR) |
||||
|
||||
HelloRequest = _reflection.GeneratedProtocolMessageType('HelloRequest', (_message.Message,), dict( |
||||
DESCRIPTOR = _HELLOREQUEST, |
||||
__module__ = 'helloworld_pb2' |
||||
# @@protoc_insertion_point(class_scope:helloworld.HelloRequest) |
||||
)) |
||||
_sym_db.RegisterMessage(HelloRequest) |
||||
|
||||
HelloReply = _reflection.GeneratedProtocolMessageType('HelloReply', (_message.Message,), dict( |
||||
DESCRIPTOR = _HELLOREPLY, |
||||
__module__ = 'helloworld_pb2' |
||||
# @@protoc_insertion_point(class_scope:helloworld.HelloReply) |
||||
)) |
||||
_sym_db.RegisterMessage(HelloReply) |
||||
|
||||
|
||||
DESCRIPTOR.has_options = True |
||||
DESCRIPTOR._options = _descriptor._ParseOptions(descriptor_pb2.FileOptions(), _b('\n\033io.grpc.examples.helloworldB\017HelloWorldProtoP\001\242\002\003HLW')) |
||||
|
||||
_GREETER = _descriptor.ServiceDescriptor( |
||||
name='Greeter', |
||||
full_name='helloworld.Greeter', |
||||
file=DESCRIPTOR, |
||||
index=0, |
||||
options=None, |
||||
serialized_start=93, |
||||
serialized_end=166, |
||||
methods=[ |
||||
_descriptor.MethodDescriptor( |
||||
name='SayHello', |
||||
full_name='helloworld.Greeter.SayHello', |
||||
index=0, |
||||
containing_service=None, |
||||
input_type=_HELLOREQUEST, |
||||
output_type=_HELLOREPLY, |
||||
options=None, |
||||
), |
||||
]) |
||||
_sym_db.RegisterServiceDescriptor(_GREETER) |
||||
|
||||
DESCRIPTOR.services_by_name['Greeter'] = _GREETER |
||||
|
||||
# @@protoc_insertion_point(module_scope) |
@ -0,0 +1,46 @@ |
||||
# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! |
||||
import grpc |
||||
|
||||
import helloworld_pb2 as helloworld__pb2 |
||||
|
||||
|
||||
class GreeterStub(object): |
||||
"""The greeting service definition. |
||||
""" |
||||
|
||||
def __init__(self, channel): |
||||
"""Constructor. |
||||
|
||||
Args: |
||||
channel: A grpc.Channel. |
||||
""" |
||||
self.SayHello = channel.unary_unary( |
||||
'/helloworld.Greeter/SayHello', |
||||
request_serializer=helloworld__pb2.HelloRequest.SerializeToString, |
||||
response_deserializer=helloworld__pb2.HelloReply.FromString, |
||||
) |
||||
|
||||
|
||||
class GreeterServicer(object): |
||||
"""The greeting service definition. |
||||
""" |
||||
|
||||
def SayHello(self, request, context): |
||||
"""Sends a greeting |
||||
""" |
||||
context.set_code(grpc.StatusCode.UNIMPLEMENTED) |
||||
context.set_details('Method not implemented!') |
||||
raise NotImplementedError('Method not implemented!') |
||||
|
||||
|
||||
def add_GreeterServicer_to_server(servicer, server): |
||||
rpc_method_handlers = { |
||||
'SayHello': grpc.unary_unary_rpc_method_handler( |
||||
servicer.SayHello, |
||||
request_deserializer=helloworld__pb2.HelloRequest.FromString, |
||||
response_serializer=helloworld__pb2.HelloReply.SerializeToString, |
||||
), |
||||
} |
||||
generic_handler = grpc.method_handlers_generic_handler( |
||||
'helloworld.Greeter', rpc_method_handlers) |
||||
server.add_generic_rpc_handlers((generic_handler,)) |
@ -1,38 +0,0 @@ |
||||
// Copyright 2015 gRPC authors. |
||||
// |
||||
// Licensed under the Apache License, Version 2.0 (the "License"); |
||||
// you may not use this file except in compliance with the License. |
||||
// You may obtain a copy of the License at |
||||
// |
||||
// http://www.apache.org/licenses/LICENSE-2.0 |
||||
// |
||||
// Unless required by applicable law or agreed to in writing, software |
||||
// distributed under the License is distributed on an "AS IS" BASIS, |
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
// See the License for the specific language governing permissions and |
||||
// limitations under the License. |
||||
|
||||
syntax = "proto3"; |
||||
|
||||
option java_multiple_files = true; |
||||
option java_package = "io.grpc.examples.helloworld"; |
||||
option java_outer_classname = "HelloWorldProto"; |
||||
option objc_class_prefix = "HLW"; |
||||
|
||||
package helloworld; |
||||
|
||||
// The greeting service definition. |
||||
service Greeter { |
||||
// Sends a greeting |
||||
rpc SayHello (HelloRequest) returns (HelloReply) {} |
||||
} |
||||
|
||||
// The request message containing the user's name. |
||||
message HelloRequest { |
||||
string name = 1; |
||||
} |
||||
|
||||
// The response message containing the greetings |
||||
message HelloReply { |
||||
string message = 1; |
||||
} |
@ -0,0 +1,134 @@ |
||||
# Generated by the protocol buffer compiler. DO NOT EDIT! |
||||
# source: helloworld.proto |
||||
|
||||
import sys |
||||
_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1')) |
||||
from google.protobuf import descriptor as _descriptor |
||||
from google.protobuf import message as _message |
||||
from google.protobuf import reflection as _reflection |
||||
from google.protobuf import symbol_database as _symbol_database |
||||
from google.protobuf import descriptor_pb2 |
||||
# @@protoc_insertion_point(imports) |
||||
|
||||
_sym_db = _symbol_database.Default() |
||||
|
||||
|
||||
|
||||
|
||||
DESCRIPTOR = _descriptor.FileDescriptor( |
||||
name='helloworld.proto', |
||||
package='helloworld', |
||||
syntax='proto3', |
||||
serialized_pb=_b('\n\x10helloworld.proto\x12\nhelloworld\"\x1c\n\x0cHelloRequest\x12\x0c\n\x04name\x18\x01 \x01(\t\"\x1d\n\nHelloReply\x12\x0f\n\x07message\x18\x01 \x01(\t2I\n\x07Greeter\x12>\n\x08SayHello\x12\x18.helloworld.HelloRequest\x1a\x16.helloworld.HelloReply\"\x00\x42\x36\n\x1bio.grpc.examples.helloworldB\x0fHelloWorldProtoP\x01\xa2\x02\x03HLWb\x06proto3') |
||||
) |
||||
|
||||
|
||||
|
||||
|
||||
_HELLOREQUEST = _descriptor.Descriptor( |
||||
name='HelloRequest', |
||||
full_name='helloworld.HelloRequest', |
||||
filename=None, |
||||
file=DESCRIPTOR, |
||||
containing_type=None, |
||||
fields=[ |
||||
_descriptor.FieldDescriptor( |
||||
name='name', full_name='helloworld.HelloRequest.name', index=0, |
||||
number=1, type=9, cpp_type=9, label=1, |
||||
has_default_value=False, default_value=_b("").decode('utf-8'), |
||||
message_type=None, enum_type=None, containing_type=None, |
||||
is_extension=False, extension_scope=None, |
||||
options=None), |
||||
], |
||||
extensions=[ |
||||
], |
||||
nested_types=[], |
||||
enum_types=[ |
||||
], |
||||
options=None, |
||||
is_extendable=False, |
||||
syntax='proto3', |
||||
extension_ranges=[], |
||||
oneofs=[ |
||||
], |
||||
serialized_start=32, |
||||
serialized_end=60, |
||||
) |
||||
|
||||
|
||||
_HELLOREPLY = _descriptor.Descriptor( |
||||
name='HelloReply', |
||||
full_name='helloworld.HelloReply', |
||||
filename=None, |
||||
file=DESCRIPTOR, |
||||
containing_type=None, |
||||
fields=[ |
||||
_descriptor.FieldDescriptor( |
||||
name='message', full_name='helloworld.HelloReply.message', index=0, |
||||
number=1, type=9, cpp_type=9, label=1, |
||||
has_default_value=False, default_value=_b("").decode('utf-8'), |
||||
message_type=None, enum_type=None, containing_type=None, |
||||
is_extension=False, extension_scope=None, |
||||
options=None), |
||||
], |
||||
extensions=[ |
||||
], |
||||
nested_types=[], |
||||
enum_types=[ |
||||
], |
||||
options=None, |
||||
is_extendable=False, |
||||
syntax='proto3', |
||||
extension_ranges=[], |
||||
oneofs=[ |
||||
], |
||||
serialized_start=62, |
||||
serialized_end=91, |
||||
) |
||||
|
||||
DESCRIPTOR.message_types_by_name['HelloRequest'] = _HELLOREQUEST |
||||
DESCRIPTOR.message_types_by_name['HelloReply'] = _HELLOREPLY |
||||
_sym_db.RegisterFileDescriptor(DESCRIPTOR) |
||||
|
||||
HelloRequest = _reflection.GeneratedProtocolMessageType('HelloRequest', (_message.Message,), dict( |
||||
DESCRIPTOR = _HELLOREQUEST, |
||||
__module__ = 'helloworld_pb2' |
||||
# @@protoc_insertion_point(class_scope:helloworld.HelloRequest) |
||||
)) |
||||
_sym_db.RegisterMessage(HelloRequest) |
||||
|
||||
HelloReply = _reflection.GeneratedProtocolMessageType('HelloReply', (_message.Message,), dict( |
||||
DESCRIPTOR = _HELLOREPLY, |
||||
__module__ = 'helloworld_pb2' |
||||
# @@protoc_insertion_point(class_scope:helloworld.HelloReply) |
||||
)) |
||||
_sym_db.RegisterMessage(HelloReply) |
||||
|
||||
|
||||
DESCRIPTOR.has_options = True |
||||
DESCRIPTOR._options = _descriptor._ParseOptions(descriptor_pb2.FileOptions(), _b('\n\033io.grpc.examples.helloworldB\017HelloWorldProtoP\001\242\002\003HLW')) |
||||
|
||||
_GREETER = _descriptor.ServiceDescriptor( |
||||
name='Greeter', |
||||
full_name='helloworld.Greeter', |
||||
file=DESCRIPTOR, |
||||
index=0, |
||||
options=None, |
||||
serialized_start=93, |
||||
serialized_end=166, |
||||
methods=[ |
||||
_descriptor.MethodDescriptor( |
||||
name='SayHello', |
||||
full_name='helloworld.Greeter.SayHello', |
||||
index=0, |
||||
containing_service=None, |
||||
input_type=_HELLOREQUEST, |
||||
output_type=_HELLOREPLY, |
||||
options=None, |
||||
), |
||||
]) |
||||
_sym_db.RegisterServiceDescriptor(_GREETER) |
||||
|
||||
DESCRIPTOR.services_by_name['Greeter'] = _GREETER |
||||
|
||||
# @@protoc_insertion_point(module_scope) |
@ -0,0 +1,46 @@ |
||||
# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! |
||||
import grpc |
||||
|
||||
import helloworld_pb2 as helloworld__pb2 |
||||
|
||||
|
||||
class GreeterStub(object): |
||||
"""The greeting service definition. |
||||
""" |
||||
|
||||
def __init__(self, channel): |
||||
"""Constructor. |
||||
|
||||
Args: |
||||
channel: A grpc.Channel. |
||||
""" |
||||
self.SayHello = channel.unary_unary( |
||||
'/helloworld.Greeter/SayHello', |
||||
request_serializer=helloworld__pb2.HelloRequest.SerializeToString, |
||||
response_deserializer=helloworld__pb2.HelloReply.FromString, |
||||
) |
||||
|
||||
|
||||
class GreeterServicer(object): |
||||
"""The greeting service definition. |
||||
""" |
||||
|
||||
def SayHello(self, request, context): |
||||
"""Sends a greeting |
||||
""" |
||||
context.set_code(grpc.StatusCode.UNIMPLEMENTED) |
||||
context.set_details('Method not implemented!') |
||||
raise NotImplementedError('Method not implemented!') |
||||
|
||||
|
||||
def add_GreeterServicer_to_server(servicer, server): |
||||
rpc_method_handlers = { |
||||
'SayHello': grpc.unary_unary_rpc_method_handler( |
||||
servicer.SayHello, |
||||
request_deserializer=helloworld__pb2.HelloRequest.FromString, |
||||
response_serializer=helloworld__pb2.HelloReply.SerializeToString, |
||||
), |
||||
} |
||||
generic_handler = grpc.method_handlers_generic_handler( |
||||
'helloworld.Greeter', rpc_method_handlers) |
||||
server.add_generic_rpc_handlers((generic_handler,)) |
@ -1,38 +0,0 @@ |
||||
// Copyright 2015 gRPC authors. |
||||
// |
||||
// Licensed under the Apache License, Version 2.0 (the "License"); |
||||
// you may not use this file except in compliance with the License. |
||||
// You may obtain a copy of the License at |
||||
// |
||||
// http://www.apache.org/licenses/LICENSE-2.0 |
||||
// |
||||
// Unless required by applicable law or agreed to in writing, software |
||||
// distributed under the License is distributed on an "AS IS" BASIS, |
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
// See the License for the specific language governing permissions and |
||||
// limitations under the License. |
||||
|
||||
syntax = "proto3"; |
||||
|
||||
option java_multiple_files = true; |
||||
option java_package = "io.grpc.examples.helloworld"; |
||||
option java_outer_classname = "HelloWorldProto"; |
||||
option objc_class_prefix = "HLW"; |
||||
|
||||
package helloworld; |
||||
|
||||
// The greeting service definition. |
||||
service Greeter { |
||||
// Sends a greeting |
||||
rpc SayHello (HelloRequest) returns (HelloReply) {} |
||||
} |
||||
|
||||
// The request message containing the user's name. |
||||
message HelloRequest { |
||||
string name = 1; |
||||
} |
||||
|
||||
// The response message containing the greetings |
||||
message HelloReply { |
||||
string message = 1; |
||||
} |
@ -0,0 +1,134 @@ |
||||
# Generated by the protocol buffer compiler. DO NOT EDIT! |
||||
# source: helloworld.proto |
||||
|
||||
import sys |
||||
_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1')) |
||||
from google.protobuf import descriptor as _descriptor |
||||
from google.protobuf import message as _message |
||||
from google.protobuf import reflection as _reflection |
||||
from google.protobuf import symbol_database as _symbol_database |
||||
from google.protobuf import descriptor_pb2 |
||||
# @@protoc_insertion_point(imports) |
||||
|
||||
_sym_db = _symbol_database.Default() |
||||
|
||||
|
||||
|
||||
|
||||
DESCRIPTOR = _descriptor.FileDescriptor( |
||||
name='helloworld.proto', |
||||
package='helloworld', |
||||
syntax='proto3', |
||||
serialized_pb=_b('\n\x10helloworld.proto\x12\nhelloworld\"\x1c\n\x0cHelloRequest\x12\x0c\n\x04name\x18\x01 \x01(\t\"\x1d\n\nHelloReply\x12\x0f\n\x07message\x18\x01 \x01(\t2I\n\x07Greeter\x12>\n\x08SayHello\x12\x18.helloworld.HelloRequest\x1a\x16.helloworld.HelloReply\"\x00\x42\x36\n\x1bio.grpc.examples.helloworldB\x0fHelloWorldProtoP\x01\xa2\x02\x03HLWb\x06proto3') |
||||
) |
||||
|
||||
|
||||
|
||||
|
||||
_HELLOREQUEST = _descriptor.Descriptor( |
||||
name='HelloRequest', |
||||
full_name='helloworld.HelloRequest', |
||||
filename=None, |
||||
file=DESCRIPTOR, |
||||
containing_type=None, |
||||
fields=[ |
||||
_descriptor.FieldDescriptor( |
||||
name='name', full_name='helloworld.HelloRequest.name', index=0, |
||||
number=1, type=9, cpp_type=9, label=1, |
||||
has_default_value=False, default_value=_b("").decode('utf-8'), |
||||
message_type=None, enum_type=None, containing_type=None, |
||||
is_extension=False, extension_scope=None, |
||||
options=None), |
||||
], |
||||
extensions=[ |
||||
], |
||||
nested_types=[], |
||||
enum_types=[ |
||||
], |
||||
options=None, |
||||
is_extendable=False, |
||||
syntax='proto3', |
||||
extension_ranges=[], |
||||
oneofs=[ |
||||
], |
||||
serialized_start=32, |
||||
serialized_end=60, |
||||
) |
||||
|
||||
|
||||
_HELLOREPLY = _descriptor.Descriptor( |
||||
name='HelloReply', |
||||
full_name='helloworld.HelloReply', |
||||
filename=None, |
||||
file=DESCRIPTOR, |
||||
containing_type=None, |
||||
fields=[ |
||||
_descriptor.FieldDescriptor( |
||||
name='message', full_name='helloworld.HelloReply.message', index=0, |
||||
number=1, type=9, cpp_type=9, label=1, |
||||
has_default_value=False, default_value=_b("").decode('utf-8'), |
||||
message_type=None, enum_type=None, containing_type=None, |
||||
is_extension=False, extension_scope=None, |
||||
options=None), |
||||
], |
||||
extensions=[ |
||||
], |
||||
nested_types=[], |
||||
enum_types=[ |
||||
], |
||||
options=None, |
||||
is_extendable=False, |
||||
syntax='proto3', |
||||
extension_ranges=[], |
||||
oneofs=[ |
||||
], |
||||
serialized_start=62, |
||||
serialized_end=91, |
||||
) |
||||
|
||||
DESCRIPTOR.message_types_by_name['HelloRequest'] = _HELLOREQUEST |
||||
DESCRIPTOR.message_types_by_name['HelloReply'] = _HELLOREPLY |
||||
_sym_db.RegisterFileDescriptor(DESCRIPTOR) |
||||
|
||||
HelloRequest = _reflection.GeneratedProtocolMessageType('HelloRequest', (_message.Message,), dict( |
||||
DESCRIPTOR = _HELLOREQUEST, |
||||
__module__ = 'helloworld_pb2' |
||||
# @@protoc_insertion_point(class_scope:helloworld.HelloRequest) |
||||
)) |
||||
_sym_db.RegisterMessage(HelloRequest) |
||||
|
||||
HelloReply = _reflection.GeneratedProtocolMessageType('HelloReply', (_message.Message,), dict( |
||||
DESCRIPTOR = _HELLOREPLY, |
||||
__module__ = 'helloworld_pb2' |
||||
# @@protoc_insertion_point(class_scope:helloworld.HelloReply) |
||||
)) |
||||
_sym_db.RegisterMessage(HelloReply) |
||||
|
||||
|
||||
DESCRIPTOR.has_options = True |
||||
DESCRIPTOR._options = _descriptor._ParseOptions(descriptor_pb2.FileOptions(), _b('\n\033io.grpc.examples.helloworldB\017HelloWorldProtoP\001\242\002\003HLW')) |
||||
|
||||
_GREETER = _descriptor.ServiceDescriptor( |
||||
name='Greeter', |
||||
full_name='helloworld.Greeter', |
||||
file=DESCRIPTOR, |
||||
index=0, |
||||
options=None, |
||||
serialized_start=93, |
||||
serialized_end=166, |
||||
methods=[ |
||||
_descriptor.MethodDescriptor( |
||||
name='SayHello', |
||||
full_name='helloworld.Greeter.SayHello', |
||||
index=0, |
||||
containing_service=None, |
||||
input_type=_HELLOREQUEST, |
||||
output_type=_HELLOREPLY, |
||||
options=None, |
||||
), |
||||
]) |
||||
_sym_db.RegisterServiceDescriptor(_GREETER) |
||||
|
||||
DESCRIPTOR.services_by_name['Greeter'] = _GREETER |
||||
|
||||
# @@protoc_insertion_point(module_scope) |
@ -0,0 +1,46 @@ |
||||
# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! |
||||
import grpc |
||||
|
||||
import helloworld_pb2 as helloworld__pb2 |
||||
|
||||
|
||||
class GreeterStub(object): |
||||
"""The greeting service definition. |
||||
""" |
||||
|
||||
def __init__(self, channel): |
||||
"""Constructor. |
||||
|
||||
Args: |
||||
channel: A grpc.Channel. |
||||
""" |
||||
self.SayHello = channel.unary_unary( |
||||
'/helloworld.Greeter/SayHello', |
||||
request_serializer=helloworld__pb2.HelloRequest.SerializeToString, |
||||
response_deserializer=helloworld__pb2.HelloReply.FromString, |
||||
) |
||||
|
||||
|
||||
class GreeterServicer(object): |
||||
"""The greeting service definition. |
||||
""" |
||||
|
||||
def SayHello(self, request, context): |
||||
"""Sends a greeting |
||||
""" |
||||
context.set_code(grpc.StatusCode.UNIMPLEMENTED) |
||||
context.set_details('Method not implemented!') |
||||
raise NotImplementedError('Method not implemented!') |
||||
|
||||
|
||||
def add_GreeterServicer_to_server(servicer, server): |
||||
rpc_method_handlers = { |
||||
'SayHello': grpc.unary_unary_rpc_method_handler( |
||||
servicer.SayHello, |
||||
request_deserializer=helloworld__pb2.HelloRequest.FromString, |
||||
response_serializer=helloworld__pb2.HelloReply.SerializeToString, |
||||
), |
||||
} |
||||
generic_handler = grpc.method_handlers_generic_handler( |
||||
'helloworld.Greeter', rpc_method_handlers) |
||||
server.add_generic_rpc_handlers((generic_handler,)) |
@ -1,38 +0,0 @@ |
||||
// Copyright 2015 gRPC authors. |
||||
// |
||||
// Licensed under the Apache License, Version 2.0 (the "License"); |
||||
// you may not use this file except in compliance with the License. |
||||
// You may obtain a copy of the License at |
||||
// |
||||
// http://www.apache.org/licenses/LICENSE-2.0 |
||||
// |
||||
// Unless required by applicable law or agreed to in writing, software |
||||
// distributed under the License is distributed on an "AS IS" BASIS, |
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
// See the License for the specific language governing permissions and |
||||
// limitations under the License. |
||||
|
||||
syntax = "proto3"; |
||||
|
||||
option java_multiple_files = true; |
||||
option java_package = "io.grpc.examples.helloworld"; |
||||
option java_outer_classname = "HelloWorldProto"; |
||||
option objc_class_prefix = "HLW"; |
||||
|
||||
package helloworld; |
||||
|
||||
// The greeting service definition. |
||||
service Greeter { |
||||
// Sends a greeting |
||||
rpc SayHello (HelloRequest) returns (HelloReply) {} |
||||
} |
||||
|
||||
// The request message containing the user's name. |
||||
message HelloRequest { |
||||
string name = 1; |
||||
} |
||||
|
||||
// The response message containing the greetings |
||||
message HelloReply { |
||||
string message = 1; |
||||
} |
@ -0,0 +1,134 @@ |
||||
# Generated by the protocol buffer compiler. DO NOT EDIT! |
||||
# source: helloworld.proto |
||||
|
||||
import sys |
||||
_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1')) |
||||
from google.protobuf import descriptor as _descriptor |
||||
from google.protobuf import message as _message |
||||
from google.protobuf import reflection as _reflection |
||||
from google.protobuf import symbol_database as _symbol_database |
||||
from google.protobuf import descriptor_pb2 |
||||
# @@protoc_insertion_point(imports) |
||||
|
||||
_sym_db = _symbol_database.Default() |
||||
|
||||
|
||||
|
||||
|
||||
DESCRIPTOR = _descriptor.FileDescriptor( |
||||
name='helloworld.proto', |
||||
package='helloworld', |
||||
syntax='proto3', |
||||
serialized_pb=_b('\n\x10helloworld.proto\x12\nhelloworld\"\x1c\n\x0cHelloRequest\x12\x0c\n\x04name\x18\x01 \x01(\t\"\x1d\n\nHelloReply\x12\x0f\n\x07message\x18\x01 \x01(\t2I\n\x07Greeter\x12>\n\x08SayHello\x12\x18.helloworld.HelloRequest\x1a\x16.helloworld.HelloReply\"\x00\x42\x36\n\x1bio.grpc.examples.helloworldB\x0fHelloWorldProtoP\x01\xa2\x02\x03HLWb\x06proto3') |
||||
) |
||||
|
||||
|
||||
|
||||
|
||||
_HELLOREQUEST = _descriptor.Descriptor( |
||||
name='HelloRequest', |
||||
full_name='helloworld.HelloRequest', |
||||
filename=None, |
||||
file=DESCRIPTOR, |
||||
containing_type=None, |
||||
fields=[ |
||||
_descriptor.FieldDescriptor( |
||||
name='name', full_name='helloworld.HelloRequest.name', index=0, |
||||
number=1, type=9, cpp_type=9, label=1, |
||||
has_default_value=False, default_value=_b("").decode('utf-8'), |
||||
message_type=None, enum_type=None, containing_type=None, |
||||
is_extension=False, extension_scope=None, |
||||
options=None), |
||||
], |
||||
extensions=[ |
||||
], |
||||
nested_types=[], |
||||
enum_types=[ |
||||
], |
||||
options=None, |
||||
is_extendable=False, |
||||
syntax='proto3', |
||||
extension_ranges=[], |
||||
oneofs=[ |
||||
], |
||||
serialized_start=32, |
||||
serialized_end=60, |
||||
) |
||||
|
||||
|
||||
_HELLOREPLY = _descriptor.Descriptor( |
||||
name='HelloReply', |
||||
full_name='helloworld.HelloReply', |
||||
filename=None, |
||||
file=DESCRIPTOR, |
||||
containing_type=None, |
||||
fields=[ |
||||
_descriptor.FieldDescriptor( |
||||
name='message', full_name='helloworld.HelloReply.message', index=0, |
||||
number=1, type=9, cpp_type=9, label=1, |
||||
has_default_value=False, default_value=_b("").decode('utf-8'), |
||||
message_type=None, enum_type=None, containing_type=None, |
||||
is_extension=False, extension_scope=None, |
||||
options=None), |
||||
], |
||||
extensions=[ |
||||
], |
||||
nested_types=[], |
||||
enum_types=[ |
||||
], |
||||
options=None, |
||||
is_extendable=False, |
||||
syntax='proto3', |
||||
extension_ranges=[], |
||||
oneofs=[ |
||||
], |
||||
serialized_start=62, |
||||
serialized_end=91, |
||||
) |
||||
|
||||
DESCRIPTOR.message_types_by_name['HelloRequest'] = _HELLOREQUEST |
||||
DESCRIPTOR.message_types_by_name['HelloReply'] = _HELLOREPLY |
||||
_sym_db.RegisterFileDescriptor(DESCRIPTOR) |
||||
|
||||
HelloRequest = _reflection.GeneratedProtocolMessageType('HelloRequest', (_message.Message,), dict( |
||||
DESCRIPTOR = _HELLOREQUEST, |
||||
__module__ = 'helloworld_pb2' |
||||
# @@protoc_insertion_point(class_scope:helloworld.HelloRequest) |
||||
)) |
||||
_sym_db.RegisterMessage(HelloRequest) |
||||
|
||||
HelloReply = _reflection.GeneratedProtocolMessageType('HelloReply', (_message.Message,), dict( |
||||
DESCRIPTOR = _HELLOREPLY, |
||||
__module__ = 'helloworld_pb2' |
||||
# @@protoc_insertion_point(class_scope:helloworld.HelloReply) |
||||
)) |
||||
_sym_db.RegisterMessage(HelloReply) |
||||
|
||||
|
||||
DESCRIPTOR.has_options = True |
||||
DESCRIPTOR._options = _descriptor._ParseOptions(descriptor_pb2.FileOptions(), _b('\n\033io.grpc.examples.helloworldB\017HelloWorldProtoP\001\242\002\003HLW')) |
||||
|
||||
_GREETER = _descriptor.ServiceDescriptor( |
||||
name='Greeter', |
||||
full_name='helloworld.Greeter', |
||||
file=DESCRIPTOR, |
||||
index=0, |
||||
options=None, |
||||
serialized_start=93, |
||||
serialized_end=166, |
||||
methods=[ |
||||
_descriptor.MethodDescriptor( |
||||
name='SayHello', |
||||
full_name='helloworld.Greeter.SayHello', |
||||
index=0, |
||||
containing_service=None, |
||||
input_type=_HELLOREQUEST, |
||||
output_type=_HELLOREPLY, |
||||
options=None, |
||||
), |
||||
]) |
||||
_sym_db.RegisterServiceDescriptor(_GREETER) |
||||
|
||||
DESCRIPTOR.services_by_name['Greeter'] = _GREETER |
||||
|
||||
# @@protoc_insertion_point(module_scope) |
@ -0,0 +1,46 @@ |
||||
# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! |
||||
import grpc |
||||
|
||||
import helloworld_pb2 as helloworld__pb2 |
||||
|
||||
|
||||
class GreeterStub(object): |
||||
"""The greeting service definition. |
||||
""" |
||||
|
||||
def __init__(self, channel): |
||||
"""Constructor. |
||||
|
||||
Args: |
||||
channel: A grpc.Channel. |
||||
""" |
||||
self.SayHello = channel.unary_unary( |
||||
'/helloworld.Greeter/SayHello', |
||||
request_serializer=helloworld__pb2.HelloRequest.SerializeToString, |
||||
response_deserializer=helloworld__pb2.HelloReply.FromString, |
||||
) |
||||
|
||||
|
||||
class GreeterServicer(object): |
||||
"""The greeting service definition. |
||||
""" |
||||
|
||||
def SayHello(self, request, context): |
||||
"""Sends a greeting |
||||
""" |
||||
context.set_code(grpc.StatusCode.UNIMPLEMENTED) |
||||
context.set_details('Method not implemented!') |
||||
raise NotImplementedError('Method not implemented!') |
||||
|
||||
|
||||
def add_GreeterServicer_to_server(servicer, server): |
||||
rpc_method_handlers = { |
||||
'SayHello': grpc.unary_unary_rpc_method_handler( |
||||
servicer.SayHello, |
||||
request_deserializer=helloworld__pb2.HelloRequest.FromString, |
||||
response_serializer=helloworld__pb2.HelloReply.SerializeToString, |
||||
), |
||||
} |
||||
generic_handler = grpc.method_handlers_generic_handler( |
||||
'helloworld.Greeter', rpc_method_handlers) |
||||
server.add_generic_rpc_handlers((generic_handler,)) |
@ -1,111 +0,0 @@ |
||||
// Copyright 2015 gRPC authors. |
||||
// |
||||
// Licensed under the Apache License, Version 2.0 (the "License"); |
||||
// you may not use this file except in compliance with the License. |
||||
// You may obtain a copy of the License at |
||||
// |
||||
// http://www.apache.org/licenses/LICENSE-2.0 |
||||
// |
||||
// Unless required by applicable law or agreed to in writing, software |
||||
// distributed under the License is distributed on an "AS IS" BASIS, |
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
// See the License for the specific language governing permissions and |
||||
// limitations under the License. |
||||
|
||||
syntax = "proto3"; |
||||
|
||||
option java_multiple_files = true; |
||||
option java_package = "io.grpc.examples.routeguide"; |
||||
option java_outer_classname = "RouteGuideProto"; |
||||
option objc_class_prefix = "RTG"; |
||||
|
||||
package routeguide; |
||||
|
||||
// Interface exported by the server. |
||||
service RouteGuide { |
||||
// A simple RPC. |
||||
// |
||||
// Obtains the feature at a given position. |
||||
// |
||||
// A feature with an empty name is returned if there's no feature at the given |
||||
// position. |
||||
rpc GetFeature(Point) returns (Feature) {} |
||||
|
||||
// A server-to-client streaming RPC. |
||||
// |
||||
// Obtains the Features available within the given Rectangle. Results are |
||||
// streamed rather than returned at once (e.g. in a response message with a |
||||
// repeated field), as the rectangle may cover a large area and contain a |
||||
// huge number of features. |
||||
rpc ListFeatures(Rectangle) returns (stream Feature) {} |
||||
|
||||
// A client-to-server streaming RPC. |
||||
// |
||||
// Accepts a stream of Points on a route being traversed, returning a |
||||
// RouteSummary when traversal is completed. |
||||
rpc RecordRoute(stream Point) returns (RouteSummary) {} |
||||
|
||||
// A Bidirectional streaming RPC. |
||||
// |
||||
// Accepts a stream of RouteNotes sent while a route is being traversed, |
||||
// while receiving other RouteNotes (e.g. from other users). |
||||
rpc RouteChat(stream RouteNote) returns (stream RouteNote) {} |
||||
} |
||||
|
||||
// Points are represented as latitude-longitude pairs in the E7 representation |
||||
// (degrees multiplied by 10**7 and rounded to the nearest integer). |
||||
// Latitudes should be in the range +/- 90 degrees and longitude should be in |
||||
// the range +/- 180 degrees (inclusive). |
||||
message Point { |
||||
int32 latitude = 1; |
||||
int32 longitude = 2; |
||||
} |
||||
|
||||
// A latitude-longitude rectangle, represented as two diagonally opposite |
||||
// points "lo" and "hi". |
||||
message Rectangle { |
||||
// One corner of the rectangle. |
||||
Point lo = 1; |
||||
|
||||
// The other corner of the rectangle. |
||||
Point hi = 2; |
||||
} |
||||
|
||||
// A feature names something at a given point. |
||||
// |
||||
// If a feature could not be named, the name is empty. |
||||
message Feature { |
||||
// The name of the feature. |
||||
string name = 1; |
||||
|
||||
// The point where the feature is detected. |
||||
Point location = 2; |
||||
} |
||||
|
||||
// A RouteNote is a message sent while at a given point. |
||||
message RouteNote { |
||||
// The location from which the message is sent. |
||||
Point location = 1; |
||||
|
||||
// The message to be sent. |
||||
string message = 2; |
||||
} |
||||
|
||||
// A RouteSummary is received in response to a RecordRoute rpc. |
||||
// |
||||
// It contains the number of individual points received, the number of |
||||
// detected features, and the total distance covered as the cumulative sum of |
||||
// the distance between each point. |
||||
message RouteSummary { |
||||
// The number of points received. |
||||
int32 point_count = 1; |
||||
|
||||
// The number of known features passed while traversing the route. |
||||
int32 feature_count = 2; |
||||
|
||||
// The distance covered in metres. |
||||
int32 distance = 3; |
||||
|
||||
// The duration of the traversal in seconds. |
||||
int32 elapsed_time = 4; |
||||
} |
@ -0,0 +1,331 @@ |
||||
# Generated by the protocol buffer compiler. DO NOT EDIT! |
||||
# source: route_guide.proto |
||||
|
||||
import sys |
||||
_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1')) |
||||
from google.protobuf import descriptor as _descriptor |
||||
from google.protobuf import message as _message |
||||
from google.protobuf import reflection as _reflection |
||||
from google.protobuf import symbol_database as _symbol_database |
||||
from google.protobuf import descriptor_pb2 |
||||
# @@protoc_insertion_point(imports) |
||||
|
||||
_sym_db = _symbol_database.Default() |
||||
|
||||
|
||||
|
||||
|
||||
DESCRIPTOR = _descriptor.FileDescriptor( |
||||
name='route_guide.proto', |
||||
package='routeguide', |
||||
syntax='proto3', |
||||
serialized_pb=_b('\n\x11route_guide.proto\x12\nrouteguide\",\n\x05Point\x12\x10\n\x08latitude\x18\x01 \x01(\x05\x12\x11\n\tlongitude\x18\x02 \x01(\x05\"I\n\tRectangle\x12\x1d\n\x02lo\x18\x01 \x01(\x0b\x32\x11.routeguide.Point\x12\x1d\n\x02hi\x18\x02 \x01(\x0b\x32\x11.routeguide.Point\"<\n\x07\x46\x65\x61ture\x12\x0c\n\x04name\x18\x01 \x01(\t\x12#\n\x08location\x18\x02 \x01(\x0b\x32\x11.routeguide.Point\"A\n\tRouteNote\x12#\n\x08location\x18\x01 \x01(\x0b\x32\x11.routeguide.Point\x12\x0f\n\x07message\x18\x02 \x01(\t\"b\n\x0cRouteSummary\x12\x13\n\x0bpoint_count\x18\x01 \x01(\x05\x12\x15\n\rfeature_count\x18\x02 \x01(\x05\x12\x10\n\x08\x64istance\x18\x03 \x01(\x05\x12\x14\n\x0c\x65lapsed_time\x18\x04 \x01(\x05\x32\x85\x02\n\nRouteGuide\x12\x36\n\nGetFeature\x12\x11.routeguide.Point\x1a\x13.routeguide.Feature\"\x00\x12>\n\x0cListFeatures\x12\x15.routeguide.Rectangle\x1a\x13.routeguide.Feature\"\x00\x30\x01\x12>\n\x0bRecordRoute\x12\x11.routeguide.Point\x1a\x18.routeguide.RouteSummary\"\x00(\x01\x12?\n\tRouteChat\x12\x15.routeguide.RouteNote\x1a\x15.routeguide.RouteNote\"\x00(\x01\x30\x01\x42\x36\n\x1bio.grpc.examples.routeguideB\x0fRouteGuideProtoP\x01\xa2\x02\x03RTGb\x06proto3') |
||||
) |
||||
|
||||
|
||||
|
||||
|
||||
_POINT = _descriptor.Descriptor( |
||||
name='Point', |
||||
full_name='routeguide.Point', |
||||
filename=None, |
||||
file=DESCRIPTOR, |
||||
containing_type=None, |
||||
fields=[ |
||||
_descriptor.FieldDescriptor( |
||||
name='latitude', full_name='routeguide.Point.latitude', index=0, |
||||
number=1, type=5, cpp_type=1, label=1, |
||||
has_default_value=False, default_value=0, |
||||
message_type=None, enum_type=None, containing_type=None, |
||||
is_extension=False, extension_scope=None, |
||||
options=None), |
||||
_descriptor.FieldDescriptor( |
||||
name='longitude', full_name='routeguide.Point.longitude', index=1, |
||||
number=2, type=5, cpp_type=1, label=1, |
||||
has_default_value=False, default_value=0, |
||||
message_type=None, enum_type=None, containing_type=None, |
||||
is_extension=False, extension_scope=None, |
||||
options=None), |
||||
], |
||||
extensions=[ |
||||
], |
||||
nested_types=[], |
||||
enum_types=[ |
||||
], |
||||
options=None, |
||||
is_extendable=False, |
||||
syntax='proto3', |
||||
extension_ranges=[], |
||||
oneofs=[ |
||||
], |
||||
serialized_start=33, |
||||
serialized_end=77, |
||||
) |
||||
|
||||
|
||||
_RECTANGLE = _descriptor.Descriptor( |
||||
name='Rectangle', |
||||
full_name='routeguide.Rectangle', |
||||
filename=None, |
||||
file=DESCRIPTOR, |
||||
containing_type=None, |
||||
fields=[ |
||||
_descriptor.FieldDescriptor( |
||||
name='lo', full_name='routeguide.Rectangle.lo', index=0, |
||||
number=1, type=11, cpp_type=10, label=1, |
||||
has_default_value=False, default_value=None, |
||||
message_type=None, enum_type=None, containing_type=None, |
||||
is_extension=False, extension_scope=None, |
||||
options=None), |
||||
_descriptor.FieldDescriptor( |
||||
name='hi', full_name='routeguide.Rectangle.hi', index=1, |
||||
number=2, type=11, cpp_type=10, label=1, |
||||
has_default_value=False, default_value=None, |
||||
message_type=None, enum_type=None, containing_type=None, |
||||
is_extension=False, extension_scope=None, |
||||
options=None), |
||||
], |
||||
extensions=[ |
||||
], |
||||
nested_types=[], |
||||
enum_types=[ |
||||
], |
||||
options=None, |
||||
is_extendable=False, |
||||
syntax='proto3', |
||||
extension_ranges=[], |
||||
oneofs=[ |
||||
], |
||||
serialized_start=79, |
||||
serialized_end=152, |
||||
) |
||||
|
||||
|
||||
_FEATURE = _descriptor.Descriptor( |
||||
name='Feature', |
||||
full_name='routeguide.Feature', |
||||
filename=None, |
||||
file=DESCRIPTOR, |
||||
containing_type=None, |
||||
fields=[ |
||||
_descriptor.FieldDescriptor( |
||||
name='name', full_name='routeguide.Feature.name', index=0, |
||||
number=1, type=9, cpp_type=9, label=1, |
||||
has_default_value=False, default_value=_b("").decode('utf-8'), |
||||
message_type=None, enum_type=None, containing_type=None, |
||||
is_extension=False, extension_scope=None, |
||||
options=None), |
||||
_descriptor.FieldDescriptor( |
||||
name='location', full_name='routeguide.Feature.location', index=1, |
||||
number=2, type=11, cpp_type=10, label=1, |
||||
has_default_value=False, default_value=None, |
||||
message_type=None, enum_type=None, containing_type=None, |
||||
is_extension=False, extension_scope=None, |
||||
options=None), |
||||
], |
||||
extensions=[ |
||||
], |
||||
nested_types=[], |
||||
enum_types=[ |
||||
], |
||||
options=None, |
||||
is_extendable=False, |
||||
syntax='proto3', |
||||
extension_ranges=[], |
||||
oneofs=[ |
||||
], |
||||
serialized_start=154, |
||||
serialized_end=214, |
||||
) |
||||
|
||||
|
||||
_ROUTENOTE = _descriptor.Descriptor( |
||||
name='RouteNote', |
||||
full_name='routeguide.RouteNote', |
||||
filename=None, |
||||
file=DESCRIPTOR, |
||||
containing_type=None, |
||||
fields=[ |
||||
_descriptor.FieldDescriptor( |
||||
name='location', full_name='routeguide.RouteNote.location', index=0, |
||||
number=1, type=11, cpp_type=10, label=1, |
||||
has_default_value=False, default_value=None, |
||||
message_type=None, enum_type=None, containing_type=None, |
||||
is_extension=False, extension_scope=None, |
||||
options=None), |
||||
_descriptor.FieldDescriptor( |
||||
name='message', full_name='routeguide.RouteNote.message', index=1, |
||||
number=2, type=9, cpp_type=9, label=1, |
||||
has_default_value=False, default_value=_b("").decode('utf-8'), |
||||
message_type=None, enum_type=None, containing_type=None, |
||||
is_extension=False, extension_scope=None, |
||||
options=None), |
||||
], |
||||
extensions=[ |
||||
], |
||||
nested_types=[], |
||||
enum_types=[ |
||||
], |
||||
options=None, |
||||
is_extendable=False, |
||||
syntax='proto3', |
||||
extension_ranges=[], |
||||
oneofs=[ |
||||
], |
||||
serialized_start=216, |
||||
serialized_end=281, |
||||
) |
||||
|
||||
|
||||
_ROUTESUMMARY = _descriptor.Descriptor( |
||||
name='RouteSummary', |
||||
full_name='routeguide.RouteSummary', |
||||
filename=None, |
||||
file=DESCRIPTOR, |
||||
containing_type=None, |
||||
fields=[ |
||||
_descriptor.FieldDescriptor( |
||||
name='point_count', full_name='routeguide.RouteSummary.point_count', index=0, |
||||
number=1, type=5, cpp_type=1, label=1, |
||||
has_default_value=False, default_value=0, |
||||
message_type=None, enum_type=None, containing_type=None, |
||||
is_extension=False, extension_scope=None, |
||||
options=None), |
||||
_descriptor.FieldDescriptor( |
||||
name='feature_count', full_name='routeguide.RouteSummary.feature_count', index=1, |
||||
number=2, type=5, cpp_type=1, label=1, |
||||
has_default_value=False, default_value=0, |
||||
message_type=None, enum_type=None, containing_type=None, |
||||
is_extension=False, extension_scope=None, |
||||
options=None), |
||||
_descriptor.FieldDescriptor( |
||||
name='distance', full_name='routeguide.RouteSummary.distance', index=2, |
||||
number=3, type=5, cpp_type=1, label=1, |
||||
has_default_value=False, default_value=0, |
||||
message_type=None, enum_type=None, containing_type=None, |
||||
is_extension=False, extension_scope=None, |
||||
options=None), |
||||
_descriptor.FieldDescriptor( |
||||
name='elapsed_time', full_name='routeguide.RouteSummary.elapsed_time', index=3, |
||||
number=4, type=5, cpp_type=1, label=1, |
||||
has_default_value=False, default_value=0, |
||||
message_type=None, enum_type=None, containing_type=None, |
||||
is_extension=False, extension_scope=None, |
||||
options=None), |
||||
], |
||||
extensions=[ |
||||
], |
||||
nested_types=[], |
||||
enum_types=[ |
||||
], |
||||
options=None, |
||||
is_extendable=False, |
||||
syntax='proto3', |
||||
extension_ranges=[], |
||||
oneofs=[ |
||||
], |
||||
serialized_start=283, |
||||
serialized_end=381, |
||||
) |
||||
|
||||
_RECTANGLE.fields_by_name['lo'].message_type = _POINT |
||||
_RECTANGLE.fields_by_name['hi'].message_type = _POINT |
||||
_FEATURE.fields_by_name['location'].message_type = _POINT |
||||
_ROUTENOTE.fields_by_name['location'].message_type = _POINT |
||||
DESCRIPTOR.message_types_by_name['Point'] = _POINT |
||||
DESCRIPTOR.message_types_by_name['Rectangle'] = _RECTANGLE |
||||
DESCRIPTOR.message_types_by_name['Feature'] = _FEATURE |
||||
DESCRIPTOR.message_types_by_name['RouteNote'] = _ROUTENOTE |
||||
DESCRIPTOR.message_types_by_name['RouteSummary'] = _ROUTESUMMARY |
||||
_sym_db.RegisterFileDescriptor(DESCRIPTOR) |
||||
|
||||
Point = _reflection.GeneratedProtocolMessageType('Point', (_message.Message,), dict( |
||||
DESCRIPTOR = _POINT, |
||||
__module__ = 'route_guide_pb2' |
||||
# @@protoc_insertion_point(class_scope:routeguide.Point) |
||||
)) |
||||
_sym_db.RegisterMessage(Point) |
||||
|
||||
Rectangle = _reflection.GeneratedProtocolMessageType('Rectangle', (_message.Message,), dict( |
||||
DESCRIPTOR = _RECTANGLE, |
||||
__module__ = 'route_guide_pb2' |
||||
# @@protoc_insertion_point(class_scope:routeguide.Rectangle) |
||||
)) |
||||
_sym_db.RegisterMessage(Rectangle) |
||||
|
||||
Feature = _reflection.GeneratedProtocolMessageType('Feature', (_message.Message,), dict( |
||||
DESCRIPTOR = _FEATURE, |
||||
__module__ = 'route_guide_pb2' |
||||
# @@protoc_insertion_point(class_scope:routeguide.Feature) |
||||
)) |
||||
_sym_db.RegisterMessage(Feature) |
||||
|
||||
RouteNote = _reflection.GeneratedProtocolMessageType('RouteNote', (_message.Message,), dict( |
||||
DESCRIPTOR = _ROUTENOTE, |
||||
__module__ = 'route_guide_pb2' |
||||
# @@protoc_insertion_point(class_scope:routeguide.RouteNote) |
||||
)) |
||||
_sym_db.RegisterMessage(RouteNote) |
||||
|
||||
RouteSummary = _reflection.GeneratedProtocolMessageType('RouteSummary', (_message.Message,), dict( |
||||
DESCRIPTOR = _ROUTESUMMARY, |
||||
__module__ = 'route_guide_pb2' |
||||
# @@protoc_insertion_point(class_scope:routeguide.RouteSummary) |
||||
)) |
||||
_sym_db.RegisterMessage(RouteSummary) |
||||
|
||||
|
||||
DESCRIPTOR.has_options = True |
||||
DESCRIPTOR._options = _descriptor._ParseOptions(descriptor_pb2.FileOptions(), _b('\n\033io.grpc.examples.routeguideB\017RouteGuideProtoP\001\242\002\003RTG')) |
||||
|
||||
_ROUTEGUIDE = _descriptor.ServiceDescriptor( |
||||
name='RouteGuide', |
||||
full_name='routeguide.RouteGuide', |
||||
file=DESCRIPTOR, |
||||
index=0, |
||||
options=None, |
||||
serialized_start=384, |
||||
serialized_end=645, |
||||
methods=[ |
||||
_descriptor.MethodDescriptor( |
||||
name='GetFeature', |
||||
full_name='routeguide.RouteGuide.GetFeature', |
||||
index=0, |
||||
containing_service=None, |
||||
input_type=_POINT, |
||||
output_type=_FEATURE, |
||||
options=None, |
||||
), |
||||
_descriptor.MethodDescriptor( |
||||
name='ListFeatures', |
||||
full_name='routeguide.RouteGuide.ListFeatures', |
||||
index=1, |
||||
containing_service=None, |
||||
input_type=_RECTANGLE, |
||||
output_type=_FEATURE, |
||||
options=None, |
||||
), |
||||
_descriptor.MethodDescriptor( |
||||
name='RecordRoute', |
||||
full_name='routeguide.RouteGuide.RecordRoute', |
||||
index=2, |
||||
containing_service=None, |
||||
input_type=_POINT, |
||||
output_type=_ROUTESUMMARY, |
||||
options=None, |
||||
), |
||||
_descriptor.MethodDescriptor( |
||||
name='RouteChat', |
||||
full_name='routeguide.RouteGuide.RouteChat', |
||||
index=3, |
||||
containing_service=None, |
||||
input_type=_ROUTENOTE, |
||||
output_type=_ROUTENOTE, |
||||
options=None, |
||||
), |
||||
]) |
||||
_sym_db.RegisterServiceDescriptor(_ROUTEGUIDE) |
||||
|
||||
DESCRIPTOR.services_by_name['RouteGuide'] = _ROUTEGUIDE |
||||
|
||||
# @@protoc_insertion_point(module_scope) |
@ -0,0 +1,113 @@ |
||||
# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! |
||||
import grpc |
||||
|
||||
import route_guide_pb2 as route__guide__pb2 |
||||
|
||||
|
||||
class RouteGuideStub(object): |
||||
"""Interface exported by the server. |
||||
""" |
||||
|
||||
def __init__(self, channel): |
||||
"""Constructor. |
||||
|
||||
Args: |
||||
channel: A grpc.Channel. |
||||
""" |
||||
self.GetFeature = channel.unary_unary( |
||||
'/routeguide.RouteGuide/GetFeature', |
||||
request_serializer=route__guide__pb2.Point.SerializeToString, |
||||
response_deserializer=route__guide__pb2.Feature.FromString, |
||||
) |
||||
self.ListFeatures = channel.unary_stream( |
||||
'/routeguide.RouteGuide/ListFeatures', |
||||
request_serializer=route__guide__pb2.Rectangle.SerializeToString, |
||||
response_deserializer=route__guide__pb2.Feature.FromString, |
||||
) |
||||
self.RecordRoute = channel.stream_unary( |
||||
'/routeguide.RouteGuide/RecordRoute', |
||||
request_serializer=route__guide__pb2.Point.SerializeToString, |
||||
response_deserializer=route__guide__pb2.RouteSummary.FromString, |
||||
) |
||||
self.RouteChat = channel.stream_stream( |
||||
'/routeguide.RouteGuide/RouteChat', |
||||
request_serializer=route__guide__pb2.RouteNote.SerializeToString, |
||||
response_deserializer=route__guide__pb2.RouteNote.FromString, |
||||
) |
||||
|
||||
|
||||
class RouteGuideServicer(object): |
||||
"""Interface exported by the server. |
||||
""" |
||||
|
||||
def GetFeature(self, request, context): |
||||
"""A simple RPC. |
||||
|
||||
Obtains the feature at a given position. |
||||
|
||||
A feature with an empty name is returned if there's no feature at the given |
||||
position. |
||||
""" |
||||
context.set_code(grpc.StatusCode.UNIMPLEMENTED) |
||||
context.set_details('Method not implemented!') |
||||
raise NotImplementedError('Method not implemented!') |
||||
|
||||
def ListFeatures(self, request, context): |
||||
"""A server-to-client streaming RPC. |
||||
|
||||
Obtains the Features available within the given Rectangle. Results are |
||||
streamed rather than returned at once (e.g. in a response message with a |
||||
repeated field), as the rectangle may cover a large area and contain a |
||||
huge number of features. |
||||
""" |
||||
context.set_code(grpc.StatusCode.UNIMPLEMENTED) |
||||
context.set_details('Method not implemented!') |
||||
raise NotImplementedError('Method not implemented!') |
||||
|
||||
def RecordRoute(self, request_iterator, context): |
||||
"""A client-to-server streaming RPC. |
||||
|
||||
Accepts a stream of Points on a route being traversed, returning a |
||||
RouteSummary when traversal is completed. |
||||
""" |
||||
context.set_code(grpc.StatusCode.UNIMPLEMENTED) |
||||
context.set_details('Method not implemented!') |
||||
raise NotImplementedError('Method not implemented!') |
||||
|
||||
def RouteChat(self, request_iterator, context): |
||||
"""A Bidirectional streaming RPC. |
||||
|
||||
Accepts a stream of RouteNotes sent while a route is being traversed, |
||||
while receiving other RouteNotes (e.g. from other users). |
||||
""" |
||||
context.set_code(grpc.StatusCode.UNIMPLEMENTED) |
||||
context.set_details('Method not implemented!') |
||||
raise NotImplementedError('Method not implemented!') |
||||
|
||||
|
||||
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,)) |
@ -0,0 +1,31 @@ |
||||
# Copyright 2016 gRPC authors. |
||||
# |
||||
# Licensed under the Apache License, Version 2.0 (the "License"); |
||||
# you may not use this file except in compliance with the License. |
||||
# You may obtain a copy of the License at |
||||
# |
||||
# http://www.apache.org/licenses/LICENSE-2.0 |
||||
# |
||||
# Unless required by applicable law or agreed to in writing, software |
||||
# distributed under the License is distributed on an "AS IS" BASIS, |
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
# See the License for the specific language governing permissions and |
||||
# limitations under the License. |
||||
"""Generates protocol messages and gRPC stubs.""" |
||||
|
||||
from grpc_tools import protoc |
||||
|
||||
protoc.main(( |
||||
'', |
||||
'-I../../protos', |
||||
'--python_out=.', |
||||
'--grpc_python_out=.', |
||||
'../../protos/helloworld.proto', |
||||
)) |
||||
protoc.main(( |
||||
'', |
||||
'-I../../protos', |
||||
'--python_out=.', |
||||
'--grpc_python_out=.', |
||||
'../../protos/route_guide.proto', |
||||
)) |
@ -1,4 +1,4 @@ |
||||
// Copyright 2015 gRPC authors. |
||||
// Copyright 2020 The gRPC authors. |
||||
// |
||||
// Licensed under the Apache License, Version 2.0 (the "License"); |
||||
// you may not use this file except in compliance with the License. |
@ -1,38 +0,0 @@ |
||||
// Copyright 2015 gRPC authors. |
||||
// |
||||
// Licensed under the Apache License, Version 2.0 (the "License"); |
||||
// you may not use this file except in compliance with the License. |
||||
// You may obtain a copy of the License at |
||||
// |
||||
// http://www.apache.org/licenses/LICENSE-2.0 |
||||
// |
||||
// Unless required by applicable law or agreed to in writing, software |
||||
// distributed under the License is distributed on an "AS IS" BASIS, |
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
// See the License for the specific language governing permissions and |
||||
// limitations under the License. |
||||
|
||||
syntax = "proto3"; |
||||
|
||||
option java_multiple_files = true; |
||||
option java_package = "io.grpc.examples.helloworld"; |
||||
option java_outer_classname = "HelloWorldProto"; |
||||
option objc_class_prefix = "HLW"; |
||||
|
||||
package helloworld; |
||||
|
||||
// The greeting service definition. |
||||
service Greeter { |
||||
// Sends a greeting |
||||
rpc SayHello (HelloRequest) returns (HelloReply) {} |
||||
} |
||||
|
||||
// The request message containing the user's name. |
||||
message HelloRequest { |
||||
string name = 1; |
||||
} |
||||
|
||||
// The response message containing the greetings |
||||
message HelloReply { |
||||
string message = 1; |
||||
} |
@ -1,111 +0,0 @@ |
||||
// Copyright 2015 gRPC authors. |
||||
// |
||||
// Licensed under the Apache License, Version 2.0 (the "License"); |
||||
// you may not use this file except in compliance with the License. |
||||
// You may obtain a copy of the License at |
||||
// |
||||
// http://www.apache.org/licenses/LICENSE-2.0 |
||||
// |
||||
// Unless required by applicable law or agreed to in writing, software |
||||
// distributed under the License is distributed on an "AS IS" BASIS, |
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
// See the License for the specific language governing permissions and |
||||
// limitations under the License. |
||||
|
||||
syntax = "proto3"; |
||||
|
||||
option java_multiple_files = true; |
||||
option java_package = "io.grpc.examples.routeguide"; |
||||
option java_outer_classname = "RouteGuideProto"; |
||||
option objc_class_prefix = "RTG"; |
||||
|
||||
package routeguide; |
||||
|
||||
// Interface exported by the server. |
||||
service RouteGuide { |
||||
// A simple RPC. |
||||
// |
||||
// Obtains the feature at a given position. |
||||
// |
||||
// A feature with an empty name is returned if there's no feature at the given |
||||
// position. |
||||
rpc GetFeature(Point) returns (Feature) {} |
||||
|
||||
// A server-to-client streaming RPC. |
||||
// |
||||
// Obtains the Features available within the given Rectangle. Results are |
||||
// streamed rather than returned at once (e.g. in a response message with a |
||||
// repeated field), as the rectangle may cover a large area and contain a |
||||
// huge number of features. |
||||
rpc ListFeatures(Rectangle) returns (stream Feature) {} |
||||
|
||||
// A client-to-server streaming RPC. |
||||
// |
||||
// Accepts a stream of Points on a route being traversed, returning a |
||||
// RouteSummary when traversal is completed. |
||||
rpc RecordRoute(stream Point) returns (RouteSummary) {} |
||||
|
||||
// A Bidirectional streaming RPC. |
||||
// |
||||
// Accepts a stream of RouteNotes sent while a route is being traversed, |
||||
// while receiving other RouteNotes (e.g. from other users). |
||||
rpc RouteChat(stream RouteNote) returns (stream RouteNote) {} |
||||
} |
||||
|
||||
// Points are represented as latitude-longitude pairs in the E7 representation |
||||
// (degrees multiplied by 10**7 and rounded to the nearest integer). |
||||
// Latitudes should be in the range +/- 90 degrees and longitude should be in |
||||
// the range +/- 180 degrees (inclusive). |
||||
message Point { |
||||
int32 latitude = 1; |
||||
int32 longitude = 2; |
||||
} |
||||
|
||||
// A latitude-longitude rectangle, represented as two diagonally opposite |
||||
// points "lo" and "hi". |
||||
message Rectangle { |
||||
// One corner of the rectangle. |
||||
Point lo = 1; |
||||
|
||||
// The other corner of the rectangle. |
||||
Point hi = 2; |
||||
} |
||||
|
||||
// A feature names something at a given point. |
||||
// |
||||
// If a feature could not be named, the name is empty. |
||||
message Feature { |
||||
// The name of the feature. |
||||
string name = 1; |
||||
|
||||
// The point where the feature is detected. |
||||
Point location = 2; |
||||
} |
||||
|
||||
// A RouteNote is a message sent while at a given point. |
||||
message RouteNote { |
||||
// The location from which the message is sent. |
||||
Point location = 1; |
||||
|
||||
// The message to be sent. |
||||
string message = 2; |
||||
} |
||||
|
||||
// A RouteSummary is received in response to a RecordRoute rpc. |
||||
// |
||||
// It contains the number of individual points received, the number of |
||||
// detected features, and the total distance covered as the cumulative sum of |
||||
// the distance between each point. |
||||
message RouteSummary { |
||||
// The number of points received. |
||||
int32 point_count = 1; |
||||
|
||||
// The number of known features passed while traversing the route. |
||||
int32 feature_count = 2; |
||||
|
||||
// The distance covered in metres. |
||||
int32 distance = 3; |
||||
|
||||
// The duration of the traversal in seconds. |
||||
int32 elapsed_time = 4; |
||||
} |
@ -0,0 +1,331 @@ |
||||
# Generated by the protocol buffer compiler. DO NOT EDIT! |
||||
# source: route_guide.proto |
||||
|
||||
import sys |
||||
_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1')) |
||||
from google.protobuf import descriptor as _descriptor |
||||
from google.protobuf import message as _message |
||||
from google.protobuf import reflection as _reflection |
||||
from google.protobuf import symbol_database as _symbol_database |
||||
from google.protobuf import descriptor_pb2 |
||||
# @@protoc_insertion_point(imports) |
||||
|
||||
_sym_db = _symbol_database.Default() |
||||
|
||||
|
||||
|
||||
|
||||
DESCRIPTOR = _descriptor.FileDescriptor( |
||||
name='route_guide.proto', |
||||
package='routeguide', |
||||
syntax='proto3', |
||||
serialized_pb=_b('\n\x11route_guide.proto\x12\nrouteguide\",\n\x05Point\x12\x10\n\x08latitude\x18\x01 \x01(\x05\x12\x11\n\tlongitude\x18\x02 \x01(\x05\"I\n\tRectangle\x12\x1d\n\x02lo\x18\x01 \x01(\x0b\x32\x11.routeguide.Point\x12\x1d\n\x02hi\x18\x02 \x01(\x0b\x32\x11.routeguide.Point\"<\n\x07\x46\x65\x61ture\x12\x0c\n\x04name\x18\x01 \x01(\t\x12#\n\x08location\x18\x02 \x01(\x0b\x32\x11.routeguide.Point\"A\n\tRouteNote\x12#\n\x08location\x18\x01 \x01(\x0b\x32\x11.routeguide.Point\x12\x0f\n\x07message\x18\x02 \x01(\t\"b\n\x0cRouteSummary\x12\x13\n\x0bpoint_count\x18\x01 \x01(\x05\x12\x15\n\rfeature_count\x18\x02 \x01(\x05\x12\x10\n\x08\x64istance\x18\x03 \x01(\x05\x12\x14\n\x0c\x65lapsed_time\x18\x04 \x01(\x05\x32\x85\x02\n\nRouteGuide\x12\x36\n\nGetFeature\x12\x11.routeguide.Point\x1a\x13.routeguide.Feature\"\x00\x12>\n\x0cListFeatures\x12\x15.routeguide.Rectangle\x1a\x13.routeguide.Feature\"\x00\x30\x01\x12>\n\x0bRecordRoute\x12\x11.routeguide.Point\x1a\x18.routeguide.RouteSummary\"\x00(\x01\x12?\n\tRouteChat\x12\x15.routeguide.RouteNote\x1a\x15.routeguide.RouteNote\"\x00(\x01\x30\x01\x42\x36\n\x1bio.grpc.examples.routeguideB\x0fRouteGuideProtoP\x01\xa2\x02\x03RTGb\x06proto3') |
||||
) |
||||
|
||||
|
||||
|
||||
|
||||
_POINT = _descriptor.Descriptor( |
||||
name='Point', |
||||
full_name='routeguide.Point', |
||||
filename=None, |
||||
file=DESCRIPTOR, |
||||
containing_type=None, |
||||
fields=[ |
||||
_descriptor.FieldDescriptor( |
||||
name='latitude', full_name='routeguide.Point.latitude', index=0, |
||||
number=1, type=5, cpp_type=1, label=1, |
||||
has_default_value=False, default_value=0, |
||||
message_type=None, enum_type=None, containing_type=None, |
||||
is_extension=False, extension_scope=None, |
||||
options=None), |
||||
_descriptor.FieldDescriptor( |
||||
name='longitude', full_name='routeguide.Point.longitude', index=1, |
||||
number=2, type=5, cpp_type=1, label=1, |
||||
has_default_value=False, default_value=0, |
||||
message_type=None, enum_type=None, containing_type=None, |
||||
is_extension=False, extension_scope=None, |
||||
options=None), |
||||
], |
||||
extensions=[ |
||||
], |
||||
nested_types=[], |
||||
enum_types=[ |
||||
], |
||||
options=None, |
||||
is_extendable=False, |
||||
syntax='proto3', |
||||
extension_ranges=[], |
||||
oneofs=[ |
||||
], |
||||
serialized_start=33, |
||||
serialized_end=77, |
||||
) |
||||
|
||||
|
||||
_RECTANGLE = _descriptor.Descriptor( |
||||
name='Rectangle', |
||||
full_name='routeguide.Rectangle', |
||||
filename=None, |
||||
file=DESCRIPTOR, |
||||
containing_type=None, |
||||
fields=[ |
||||
_descriptor.FieldDescriptor( |
||||
name='lo', full_name='routeguide.Rectangle.lo', index=0, |
||||
number=1, type=11, cpp_type=10, label=1, |
||||
has_default_value=False, default_value=None, |
||||
message_type=None, enum_type=None, containing_type=None, |
||||
is_extension=False, extension_scope=None, |
||||
options=None), |
||||
_descriptor.FieldDescriptor( |
||||
name='hi', full_name='routeguide.Rectangle.hi', index=1, |
||||
number=2, type=11, cpp_type=10, label=1, |
||||
has_default_value=False, default_value=None, |
||||
message_type=None, enum_type=None, containing_type=None, |
||||
is_extension=False, extension_scope=None, |
||||
options=None), |
||||
], |
||||
extensions=[ |
||||
], |
||||
nested_types=[], |
||||
enum_types=[ |
||||
], |
||||
options=None, |
||||
is_extendable=False, |
||||
syntax='proto3', |
||||
extension_ranges=[], |
||||
oneofs=[ |
||||
], |
||||
serialized_start=79, |
||||
serialized_end=152, |
||||
) |
||||
|
||||
|
||||
_FEATURE = _descriptor.Descriptor( |
||||
name='Feature', |
||||
full_name='routeguide.Feature', |
||||
filename=None, |
||||
file=DESCRIPTOR, |
||||
containing_type=None, |
||||
fields=[ |
||||
_descriptor.FieldDescriptor( |
||||
name='name', full_name='routeguide.Feature.name', index=0, |
||||
number=1, type=9, cpp_type=9, label=1, |
||||
has_default_value=False, default_value=_b("").decode('utf-8'), |
||||
message_type=None, enum_type=None, containing_type=None, |
||||
is_extension=False, extension_scope=None, |
||||
options=None), |
||||
_descriptor.FieldDescriptor( |
||||
name='location', full_name='routeguide.Feature.location', index=1, |
||||
number=2, type=11, cpp_type=10, label=1, |
||||
has_default_value=False, default_value=None, |
||||
message_type=None, enum_type=None, containing_type=None, |
||||
is_extension=False, extension_scope=None, |
||||
options=None), |
||||
], |
||||
extensions=[ |
||||
], |
||||
nested_types=[], |
||||
enum_types=[ |
||||
], |
||||
options=None, |
||||
is_extendable=False, |
||||
syntax='proto3', |
||||
extension_ranges=[], |
||||
oneofs=[ |
||||
], |
||||
serialized_start=154, |
||||
serialized_end=214, |
||||
) |
||||
|
||||
|
||||
_ROUTENOTE = _descriptor.Descriptor( |
||||
name='RouteNote', |
||||
full_name='routeguide.RouteNote', |
||||
filename=None, |
||||
file=DESCRIPTOR, |
||||
containing_type=None, |
||||
fields=[ |
||||
_descriptor.FieldDescriptor( |
||||
name='location', full_name='routeguide.RouteNote.location', index=0, |
||||
number=1, type=11, cpp_type=10, label=1, |
||||
has_default_value=False, default_value=None, |
||||
message_type=None, enum_type=None, containing_type=None, |
||||
is_extension=False, extension_scope=None, |
||||
options=None), |
||||
_descriptor.FieldDescriptor( |
||||
name='message', full_name='routeguide.RouteNote.message', index=1, |
||||
number=2, type=9, cpp_type=9, label=1, |
||||
has_default_value=False, default_value=_b("").decode('utf-8'), |
||||
message_type=None, enum_type=None, containing_type=None, |
||||
is_extension=False, extension_scope=None, |
||||
options=None), |
||||
], |
||||
extensions=[ |
||||
], |
||||
nested_types=[], |
||||
enum_types=[ |
||||
], |
||||
options=None, |
||||
is_extendable=False, |
||||
syntax='proto3', |
||||
extension_ranges=[], |
||||
oneofs=[ |
||||
], |
||||
serialized_start=216, |
||||
serialized_end=281, |
||||
) |
||||
|
||||
|
||||
_ROUTESUMMARY = _descriptor.Descriptor( |
||||
name='RouteSummary', |
||||
full_name='routeguide.RouteSummary', |
||||
filename=None, |
||||
file=DESCRIPTOR, |
||||
containing_type=None, |
||||
fields=[ |
||||
_descriptor.FieldDescriptor( |
||||
name='point_count', full_name='routeguide.RouteSummary.point_count', index=0, |
||||
number=1, type=5, cpp_type=1, label=1, |
||||
has_default_value=False, default_value=0, |
||||
message_type=None, enum_type=None, containing_type=None, |
||||
is_extension=False, extension_scope=None, |
||||
options=None), |
||||
_descriptor.FieldDescriptor( |
||||
name='feature_count', full_name='routeguide.RouteSummary.feature_count', index=1, |
||||
number=2, type=5, cpp_type=1, label=1, |
||||
has_default_value=False, default_value=0, |
||||
message_type=None, enum_type=None, containing_type=None, |
||||
is_extension=False, extension_scope=None, |
||||
options=None), |
||||
_descriptor.FieldDescriptor( |
||||
name='distance', full_name='routeguide.RouteSummary.distance', index=2, |
||||
number=3, type=5, cpp_type=1, label=1, |
||||
has_default_value=False, default_value=0, |
||||
message_type=None, enum_type=None, containing_type=None, |
||||
is_extension=False, extension_scope=None, |
||||
options=None), |
||||
_descriptor.FieldDescriptor( |
||||
name='elapsed_time', full_name='routeguide.RouteSummary.elapsed_time', index=3, |
||||
number=4, type=5, cpp_type=1, label=1, |
||||
has_default_value=False, default_value=0, |
||||
message_type=None, enum_type=None, containing_type=None, |
||||
is_extension=False, extension_scope=None, |
||||
options=None), |
||||
], |
||||
extensions=[ |
||||
], |
||||
nested_types=[], |
||||
enum_types=[ |
||||
], |
||||
options=None, |
||||
is_extendable=False, |
||||
syntax='proto3', |
||||
extension_ranges=[], |
||||
oneofs=[ |
||||
], |
||||
serialized_start=283, |
||||
serialized_end=381, |
||||
) |
||||
|
||||
_RECTANGLE.fields_by_name['lo'].message_type = _POINT |
||||
_RECTANGLE.fields_by_name['hi'].message_type = _POINT |
||||
_FEATURE.fields_by_name['location'].message_type = _POINT |
||||
_ROUTENOTE.fields_by_name['location'].message_type = _POINT |
||||
DESCRIPTOR.message_types_by_name['Point'] = _POINT |
||||
DESCRIPTOR.message_types_by_name['Rectangle'] = _RECTANGLE |
||||
DESCRIPTOR.message_types_by_name['Feature'] = _FEATURE |
||||
DESCRIPTOR.message_types_by_name['RouteNote'] = _ROUTENOTE |
||||
DESCRIPTOR.message_types_by_name['RouteSummary'] = _ROUTESUMMARY |
||||
_sym_db.RegisterFileDescriptor(DESCRIPTOR) |
||||
|
||||
Point = _reflection.GeneratedProtocolMessageType('Point', (_message.Message,), dict( |
||||
DESCRIPTOR = _POINT, |
||||
__module__ = 'route_guide_pb2' |
||||
# @@protoc_insertion_point(class_scope:routeguide.Point) |
||||
)) |
||||
_sym_db.RegisterMessage(Point) |
||||
|
||||
Rectangle = _reflection.GeneratedProtocolMessageType('Rectangle', (_message.Message,), dict( |
||||
DESCRIPTOR = _RECTANGLE, |
||||
__module__ = 'route_guide_pb2' |
||||
# @@protoc_insertion_point(class_scope:routeguide.Rectangle) |
||||
)) |
||||
_sym_db.RegisterMessage(Rectangle) |
||||
|
||||
Feature = _reflection.GeneratedProtocolMessageType('Feature', (_message.Message,), dict( |
||||
DESCRIPTOR = _FEATURE, |
||||
__module__ = 'route_guide_pb2' |
||||
# @@protoc_insertion_point(class_scope:routeguide.Feature) |
||||
)) |
||||
_sym_db.RegisterMessage(Feature) |
||||
|
||||
RouteNote = _reflection.GeneratedProtocolMessageType('RouteNote', (_message.Message,), dict( |
||||
DESCRIPTOR = _ROUTENOTE, |
||||
__module__ = 'route_guide_pb2' |
||||
# @@protoc_insertion_point(class_scope:routeguide.RouteNote) |
||||
)) |
||||
_sym_db.RegisterMessage(RouteNote) |
||||
|
||||
RouteSummary = _reflection.GeneratedProtocolMessageType('RouteSummary', (_message.Message,), dict( |
||||
DESCRIPTOR = _ROUTESUMMARY, |
||||
__module__ = 'route_guide_pb2' |
||||
# @@protoc_insertion_point(class_scope:routeguide.RouteSummary) |
||||
)) |
||||
_sym_db.RegisterMessage(RouteSummary) |
||||
|
||||
|
||||
DESCRIPTOR.has_options = True |
||||
DESCRIPTOR._options = _descriptor._ParseOptions(descriptor_pb2.FileOptions(), _b('\n\033io.grpc.examples.routeguideB\017RouteGuideProtoP\001\242\002\003RTG')) |
||||
|
||||
_ROUTEGUIDE = _descriptor.ServiceDescriptor( |
||||
name='RouteGuide', |
||||
full_name='routeguide.RouteGuide', |
||||
file=DESCRIPTOR, |
||||
index=0, |
||||
options=None, |
||||
serialized_start=384, |
||||
serialized_end=645, |
||||
methods=[ |
||||
_descriptor.MethodDescriptor( |
||||
name='GetFeature', |
||||
full_name='routeguide.RouteGuide.GetFeature', |
||||
index=0, |
||||
containing_service=None, |
||||
input_type=_POINT, |
||||
output_type=_FEATURE, |
||||
options=None, |
||||
), |
||||
_descriptor.MethodDescriptor( |
||||
name='ListFeatures', |
||||
full_name='routeguide.RouteGuide.ListFeatures', |
||||
index=1, |
||||
containing_service=None, |
||||
input_type=_RECTANGLE, |
||||
output_type=_FEATURE, |
||||
options=None, |
||||
), |
||||
_descriptor.MethodDescriptor( |
||||
name='RecordRoute', |
||||
full_name='routeguide.RouteGuide.RecordRoute', |
||||
index=2, |
||||
containing_service=None, |
||||
input_type=_POINT, |
||||
output_type=_ROUTESUMMARY, |
||||
options=None, |
||||
), |
||||
_descriptor.MethodDescriptor( |
||||
name='RouteChat', |
||||
full_name='routeguide.RouteGuide.RouteChat', |
||||
index=3, |
||||
containing_service=None, |
||||
input_type=_ROUTENOTE, |
||||
output_type=_ROUTENOTE, |
||||
options=None, |
||||
), |
||||
]) |
||||
_sym_db.RegisterServiceDescriptor(_ROUTEGUIDE) |
||||
|
||||
DESCRIPTOR.services_by_name['RouteGuide'] = _ROUTEGUIDE |
||||
|
||||
# @@protoc_insertion_point(module_scope) |
@ -0,0 +1,113 @@ |
||||
# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! |
||||
import grpc |
||||
|
||||
import route_guide_pb2 as route__guide__pb2 |
||||
|
||||
|
||||
class RouteGuideStub(object): |
||||
"""Interface exported by the server. |
||||
""" |
||||
|
||||
def __init__(self, channel): |
||||
"""Constructor. |
||||
|
||||
Args: |
||||
channel: A grpc.Channel. |
||||
""" |
||||
self.GetFeature = channel.unary_unary( |
||||
'/routeguide.RouteGuide/GetFeature', |
||||
request_serializer=route__guide__pb2.Point.SerializeToString, |
||||
response_deserializer=route__guide__pb2.Feature.FromString, |
||||
) |
||||
self.ListFeatures = channel.unary_stream( |
||||
'/routeguide.RouteGuide/ListFeatures', |
||||
request_serializer=route__guide__pb2.Rectangle.SerializeToString, |
||||
response_deserializer=route__guide__pb2.Feature.FromString, |
||||
) |
||||
self.RecordRoute = channel.stream_unary( |
||||
'/routeguide.RouteGuide/RecordRoute', |
||||
request_serializer=route__guide__pb2.Point.SerializeToString, |
||||
response_deserializer=route__guide__pb2.RouteSummary.FromString, |
||||
) |
||||
self.RouteChat = channel.stream_stream( |
||||
'/routeguide.RouteGuide/RouteChat', |
||||
request_serializer=route__guide__pb2.RouteNote.SerializeToString, |
||||
response_deserializer=route__guide__pb2.RouteNote.FromString, |
||||
) |
||||
|
||||
|
||||
class RouteGuideServicer(object): |
||||
"""Interface exported by the server. |
||||
""" |
||||
|
||||
def GetFeature(self, request, context): |
||||
"""A simple RPC. |
||||
|
||||
Obtains the feature at a given position. |
||||
|
||||
A feature with an empty name is returned if there's no feature at the given |
||||
position. |
||||
""" |
||||
context.set_code(grpc.StatusCode.UNIMPLEMENTED) |
||||
context.set_details('Method not implemented!') |
||||
raise NotImplementedError('Method not implemented!') |
||||
|
||||
def ListFeatures(self, request, context): |
||||
"""A server-to-client streaming RPC. |
||||
|
||||
Obtains the Features available within the given Rectangle. Results are |
||||
streamed rather than returned at once (e.g. in a response message with a |
||||
repeated field), as the rectangle may cover a large area and contain a |
||||
huge number of features. |
||||
""" |
||||
context.set_code(grpc.StatusCode.UNIMPLEMENTED) |
||||
context.set_details('Method not implemented!') |
||||
raise NotImplementedError('Method not implemented!') |
||||
|
||||
def RecordRoute(self, request_iterator, context): |
||||
"""A client-to-server streaming RPC. |
||||
|
||||
Accepts a stream of Points on a route being traversed, returning a |
||||
RouteSummary when traversal is completed. |
||||
""" |
||||
context.set_code(grpc.StatusCode.UNIMPLEMENTED) |
||||
context.set_details('Method not implemented!') |
||||
raise NotImplementedError('Method not implemented!') |
||||
|
||||
def RouteChat(self, request_iterator, context): |
||||
"""A Bidirectional streaming RPC. |
||||
|
||||
Accepts a stream of RouteNotes sent while a route is being traversed, |
||||
while receiving other RouteNotes (e.g. from other users). |
||||
""" |
||||
context.set_code(grpc.StatusCode.UNIMPLEMENTED) |
||||
context.set_details('Method not implemented!') |
||||
raise NotImplementedError('Method not implemented!') |
||||
|
||||
|
||||
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,)) |
@ -0,0 +1,24 @@ |
||||
# Copyright 2015 gRPC authors. |
||||
# |
||||
# Licensed under the Apache License, Version 2.0 (the "License"); |
||||
# you may not use this file except in compliance with the License. |
||||
# You may obtain a copy of the License at |
||||
# |
||||
# http://www.apache.org/licenses/LICENSE-2.0 |
||||
# |
||||
# Unless required by applicable law or agreed to in writing, software |
||||
# distributed under the License is distributed on an "AS IS" BASIS, |
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
# See the License for the specific language governing permissions and |
||||
# limitations under the License. |
||||
"""Runs protoc with the gRPC plugin to generate messages and gRPC stubs.""" |
||||
|
||||
from grpc_tools import protoc |
||||
|
||||
protoc.main(( |
||||
'', |
||||
'-I../../protos', |
||||
'--python_out=.', |
||||
'--grpc_python_out=.', |
||||
'../../protos/route_guide.proto', |
||||
)) |
@ -1,38 +0,0 @@ |
||||
// Copyright 2015 gRPC authors. |
||||
// |
||||
// Licensed under the Apache License, Version 2.0 (the "License"); |
||||
// you may not use this file except in compliance with the License. |
||||
// You may obtain a copy of the License at |
||||
// |
||||
// http://www.apache.org/licenses/LICENSE-2.0 |
||||
// |
||||
// Unless required by applicable law or agreed to in writing, software |
||||
// distributed under the License is distributed on an "AS IS" BASIS, |
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
// See the License for the specific language governing permissions and |
||||
// limitations under the License. |
||||
|
||||
syntax = "proto3"; |
||||
|
||||
option java_multiple_files = true; |
||||
option java_package = "io.grpc.examples.helloworld"; |
||||
option java_outer_classname = "HelloWorldProto"; |
||||
option objc_class_prefix = "HLW"; |
||||
|
||||
package helloworld; |
||||
|
||||
// The greeting service definition. |
||||
service Greeter { |
||||
// Sends a greeting |
||||
rpc SayHello (HelloRequest) returns (HelloReply) {} |
||||
} |
||||
|
||||
// The request message containing the user's name. |
||||
message HelloRequest { |
||||
string name = 1; |
||||
} |
||||
|
||||
// The response message containing the greetings |
||||
message HelloReply { |
||||
string message = 1; |
||||
} |
Loading…
Reference in new issue