Skip to content

Commit

Permalink
Sync examples/trace/grpc proto file with other opencensus projects (#146
Browse files Browse the repository at this point in the history
)
  • Loading branch information
wkiser authored and liyanhui1228 committed Apr 2, 2018
1 parent 2ac053e commit 471939e
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 29 deletions.
8 changes: 7 additions & 1 deletion examples/trace/grpc/hello_world.proto
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,14 @@

syntax = "proto3";

option java_multiple_files = true;
option java_package = "io.grpc.examples.helloworld";
option java_outer_classname = "HelloWorldProto";

package helloworld;

// The hello world service definition.
service HelloWorld {
service Greeter {
// Say hello to the request sender (unary-unary)
rpc SayHello (HelloRequest) returns (HelloReply) {}
}
Expand Down
2 changes: 1 addition & 1 deletion examples/trace/grpc/hello_world_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def main():
host_port=HOST_PORT)
channel = grpc.insecure_channel(HOST_PORT)
channel = grpc.intercept_channel(channel, tracer_interceptor)
stub = hello_world_pb2_grpc.HelloWorldStub(channel)
stub = hello_world_pb2_grpc.GreeterStub(channel)
response = stub.SayHello(hello_world_pb2.HelloRequest(name='you'))
print("Message received: " + response.message)

Expand Down
42 changes: 22 additions & 20 deletions examples/trace/grpc/hello_world_pb2.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions examples/trace/grpc/hello_world_pb2_grpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import hello_world_pb2 as hello__world__pb2


class HelloWorldStub(object):
class GreeterStub(object):
"""The hello world service definition.
"""

Expand All @@ -15,13 +15,13 @@ def __init__(self, channel):
channel: A grpc.Channel.
"""
self.SayHello = channel.unary_unary(
'/HelloWorld/SayHello',
'/helloworld.Greeter/SayHello',
request_serializer=hello__world__pb2.HelloRequest.SerializeToString,
response_deserializer=hello__world__pb2.HelloReply.FromString,
)


class HelloWorldServicer(object):
class GreeterServicer(object):
"""The hello world service definition.
"""

Expand All @@ -33,7 +33,7 @@ def SayHello(self, request, context):
raise NotImplementedError('Method not implemented!')


def add_HelloWorldServicer_to_server(servicer, server):
def add_GreeterServicer_to_server(servicer, server):
rpc_method_handlers = {
'SayHello': grpc.unary_unary_rpc_method_handler(
servicer.SayHello,
Expand All @@ -42,5 +42,5 @@ def add_HelloWorldServicer_to_server(servicer, server):
),
}
generic_handler = grpc.method_handlers_generic_handler(
'HelloWorld', rpc_method_handlers)
'helloworld.Greeter', rpc_method_handlers)
server.add_generic_rpc_handlers((generic_handler,))
4 changes: 2 additions & 2 deletions examples/trace/grpc/hello_world_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
_ONE_DAY_IN_SECONDS = 60 * 60 * 24


class HelloWorld(hello_world_pb2_grpc.HelloWorldServicer):
class HelloWorld(hello_world_pb2_grpc.GreeterServicer):

def SayHello(self, request, context):
return hello_world_pb2.HelloReply(message='Hello, %s!' % request.name)
Expand All @@ -41,7 +41,7 @@ def serve():
server = grpc.server(
futures.ThreadPoolExecutor(max_workers=10),
interceptors=(tracer_interceptor,))
hello_world_pb2_grpc.add_HelloWorldServicer_to_server(HelloWorld(), server)
hello_world_pb2_grpc.add_GreeterServicer_to_server(HelloWorld(), server)
server.add_insecure_port('[::]:50051')
server.start()
try:
Expand Down

0 comments on commit 471939e

Please sign in to comment.