change proto README cpp node ruby

pull/3109/head
Yang Gao 10 years ago
parent 4eb1a89218
commit 600d70cd8d
  1. 6
      README.md
  2. 2
      cpp/helloworld/greeter_client.cc
  3. 2
      cpp/helloworld/greeter_server.cc
  4. 14
      cpp/helloworld/helloworld.pb.cc
  5. 8
      cpp/helloworld/helloworld.pb.h
  6. 2
      node/greeter_client.js
  7. 6
      node/greeter_server.js
  8. 2
      node/helloworld.proto
  9. 2
      protos/helloworld.proto
  10. 2
      ruby/greeter_server.rb
  11. 2
      ruby/lib/helloworld_services.rb

@ -187,7 +187,7 @@ package helloworld;
// The greeting service definition. // The greeting service definition.
service Greeter { service Greeter {
// Sends a greeting // Sends a greeting
rpc sayHello (HelloRequest) returns (HelloReply) {} rpc SayHello (HelloRequest) returns (HelloReply) {}
} }
// The request message containing the user's name. // The request message containing the user's name.
@ -254,7 +254,7 @@ which contains (along with some other useful code):
```java ```java
public static interface Greeter { public static interface Greeter {
public void sayHello(ex.grpc.Helloworld.HelloRequest request, public void SayHello(ex.grpc.Helloworld.HelloRequest request,
com.google.net.stubby.stub.StreamObserver<ex.grpc.Helloworld.HelloReply> com.google.net.stubby.stub.StreamObserver<ex.grpc.Helloworld.HelloReply>
responseObserver); responseObserver);
} }
@ -405,7 +405,7 @@ from which we can get our greeting.
try { try {
Helloworld.HelloRequest request = Helloworld.HelloRequest request =
Helloworld.HelloRequest.newBuilder().setName(name).build(); Helloworld.HelloRequest.newBuilder().setName(name).build();
Helloworld.HelloReply reply = blockingStub.sayHello(request); Helloworld.HelloReply reply = blockingStub.SayHello(request);
logger.info("Greeting: " + reply.getMessage()); logger.info("Greeting: " + reply.getMessage());
} catch (RuntimeException e) { } catch (RuntimeException e) {
logger.log(Level.WARNING, "RPC failed", e); logger.log(Level.WARNING, "RPC failed", e);

@ -62,7 +62,7 @@ class GreeterClient {
HelloReply reply; HelloReply reply;
ClientContext context; ClientContext context;
Status status = stub_->sayHello(&context, request, &reply); Status status = stub_->SayHello(&context, request, &reply);
if (status.IsOk()) { if (status.IsOk()) {
return reply.message(); return reply.message();
} else { } else {

@ -52,7 +52,7 @@ using helloworld::HelloReply;
using helloworld::Greeter; using helloworld::Greeter;
class GreeterServiceImpl final : public Greeter::Service { class GreeterServiceImpl final : public Greeter::Service {
Status sayHello(ServerContext* context, const HelloRequest* request, Status SayHello(ServerContext* context, const HelloRequest* request,
HelloReply* reply) override { HelloReply* reply) override {
std::string prefix("Hello "); std::string prefix("Hello ");
reply->set_message(prefix + request->name()); reply->set_message(prefix + request->name());

@ -109,7 +109,7 @@ void protobuf_AddDesc_helloworld_2eproto() {
::google::protobuf::DescriptorPool::InternalAddGeneratedFile( ::google::protobuf::DescriptorPool::InternalAddGeneratedFile(
"\n\020helloworld.proto\022\nhelloworld\"\034\n\014HelloR" "\n\020helloworld.proto\022\nhelloworld\"\034\n\014HelloR"
"equest\022\014\n\004name\030\001 \001(\t\"\035\n\nHelloReply\022\017\n\007me" "equest\022\014\n\004name\030\001 \001(\t\"\035\n\nHelloReply\022\017\n\007me"
"ssage\030\001 \001(\t2I\n\007Greeter\022>\n\010sayHello\022\030.hel" "ssage\030\001 \001(\t2I\n\007Greeter\022>\n\010SayHello\022\030.hel"
"loworld.HelloRequest\032\026.helloworld.HelloR" "loworld.HelloRequest\032\026.helloworld.HelloR"
"eply\"\000B\t\n\007ex.grpcb\006proto3", 185); "eply\"\000B\t\n\007ex.grpcb\006proto3", 185);
::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile(
@ -587,7 +587,7 @@ void HelloReply::InternalSwap(HelloReply* other) {
static const char* Greeter_method_names[] = { static const char* Greeter_method_names[] = {
"/helloworld.Greeter/sayHello", "/helloworld.Greeter/SayHello",
}; };
Greeter::Stub* Greeter::NewStub(const std::shared_ptr< ::grpc::ChannelInterface>& channel) { Greeter::Stub* Greeter::NewStub(const std::shared_ptr< ::grpc::ChannelInterface>& channel) {
@ -596,11 +596,11 @@ Greeter::Stub* Greeter::NewStub(const std::shared_ptr< ::grpc::ChannelInterface>
return stub; return stub;
}; };
::grpc::Status Greeter::Stub::sayHello(::grpc::ClientContext* context, const ::helloworld::HelloRequest& request, ::helloworld::HelloReply* response) { ::grpc::Status Greeter::Stub::SayHello(::grpc::ClientContext* context, const ::helloworld::HelloRequest& request, ::helloworld::HelloReply* response) {
return ::grpc::BlockingUnaryCall(channel(),::grpc::RpcMethod(Greeter_method_names[0]), context, request, response); return ::grpc::BlockingUnaryCall(channel(),::grpc::RpcMethod(Greeter_method_names[0]), context, request, response);
} }
::grpc::ClientAsyncResponseReader< ::helloworld::HelloReply>* Greeter::Stub::sayHello(::grpc::ClientContext* context, const ::helloworld::HelloRequest& request, ::grpc::CompletionQueue* cq, void* tag) { ::grpc::ClientAsyncResponseReader< ::helloworld::HelloReply>* Greeter::Stub::SayHello(::grpc::ClientContext* context, const ::helloworld::HelloRequest& request, ::grpc::CompletionQueue* cq, void* tag) {
return new ::grpc::ClientAsyncResponseReader< ::helloworld::HelloReply>(channel(), cq, ::grpc::RpcMethod(Greeter_method_names[0]), context, request, tag); return new ::grpc::ClientAsyncResponseReader< ::helloworld::HelloReply>(channel(), cq, ::grpc::RpcMethod(Greeter_method_names[0]), context, request, tag);
} }
@ -610,11 +610,11 @@ Greeter::Service::~Service() {
delete service_; delete service_;
} }
::grpc::Status Greeter::Service::sayHello(::grpc::ServerContext* context, const ::helloworld::HelloRequest* request, ::helloworld::HelloReply* response) { ::grpc::Status Greeter::Service::SayHello(::grpc::ServerContext* context, const ::helloworld::HelloRequest* request, ::helloworld::HelloReply* response) {
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED); return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED);
} }
void Greeter::AsyncService::RequestsayHello(::grpc::ServerContext* context, ::helloworld::HelloRequest* request, ::grpc::ServerAsyncResponseWriter< ::helloworld::HelloReply>* response, ::grpc::CompletionQueue* cq, void* tag) { void Greeter::AsyncService::RequestSayHello(::grpc::ServerContext* context, ::helloworld::HelloRequest* request, ::grpc::ServerAsyncResponseWriter< ::helloworld::HelloReply>* response, ::grpc::CompletionQueue* cq, void* tag) {
AsynchronousService::RequestAsyncUnary(0, context, request, response, cq, tag); AsynchronousService::RequestAsyncUnary(0, context, request, response, cq, tag);
} }
@ -627,7 +627,7 @@ void Greeter::AsyncService::RequestsayHello(::grpc::ServerContext* context, ::he
Greeter_method_names[0], Greeter_method_names[0],
::grpc::RpcMethod::NORMAL_RPC, ::grpc::RpcMethod::NORMAL_RPC,
new ::grpc::RpcMethodHandler< Greeter::Service, ::helloworld::HelloRequest, ::helloworld::HelloReply>( new ::grpc::RpcMethodHandler< Greeter::Service, ::helloworld::HelloRequest, ::helloworld::HelloReply>(
std::function< ::grpc::Status(Greeter::Service*, ::grpc::ServerContext*, const ::helloworld::HelloRequest*, ::helloworld::HelloReply*)>(&Greeter::Service::sayHello), this), std::function< ::grpc::Status(Greeter::Service*, ::grpc::ServerContext*, const ::helloworld::HelloRequest*, ::helloworld::HelloReply*)>(&Greeter::Service::SayHello), this),
new ::helloworld::HelloRequest, new ::helloworld::HelloReply)); new ::helloworld::HelloRequest, new ::helloworld::HelloReply));
return service_; return service_;
} }

@ -319,8 +319,8 @@ class Greeter final {
public: public:
class Stub final : public ::grpc::InternalStub { class Stub final : public ::grpc::InternalStub {
public: public:
::grpc::Status sayHello(::grpc::ClientContext* context, const ::helloworld::HelloRequest& request, ::helloworld::HelloReply* response); ::grpc::Status SayHello(::grpc::ClientContext* context, const ::helloworld::HelloRequest& request, ::helloworld::HelloReply* response);
::grpc::ClientAsyncResponseReader< ::helloworld::HelloReply>* sayHello(::grpc::ClientContext* context, const ::helloworld::HelloRequest& request, ::grpc::CompletionQueue* cq, void* tag); ::grpc::ClientAsyncResponseReader< ::helloworld::HelloReply>* SayHello(::grpc::ClientContext* context, const ::helloworld::HelloRequest& request, ::grpc::CompletionQueue* cq, void* tag);
}; };
static Stub* NewStub(const std::shared_ptr< ::grpc::ChannelInterface>& channel); static Stub* NewStub(const std::shared_ptr< ::grpc::ChannelInterface>& channel);
@ -328,7 +328,7 @@ class Greeter final {
public: public:
Service() : service_(nullptr) {} Service() : service_(nullptr) {}
virtual ~Service(); virtual ~Service();
virtual ::grpc::Status sayHello(::grpc::ServerContext* context, const ::helloworld::HelloRequest* request, ::helloworld::HelloReply* response); virtual ::grpc::Status SayHello(::grpc::ServerContext* context, const ::helloworld::HelloRequest* request, ::helloworld::HelloReply* response);
::grpc::RpcService* service() override final; ::grpc::RpcService* service() override final;
private: private:
::grpc::RpcService* service_; ::grpc::RpcService* service_;
@ -337,7 +337,7 @@ class Greeter final {
public: public:
explicit AsyncService(::grpc::CompletionQueue* cq); explicit AsyncService(::grpc::CompletionQueue* cq);
~AsyncService() {}; ~AsyncService() {};
void RequestsayHello(::grpc::ServerContext* context, ::helloworld::HelloRequest* request, ::grpc::ServerAsyncResponseWriter< ::helloworld::HelloReply>* response, ::grpc::CompletionQueue* cq, void *tag); void RequestSayHello(::grpc::ServerContext* context, ::helloworld::HelloRequest* request, ::grpc::ServerAsyncResponseWriter< ::helloworld::HelloReply>* response, ::grpc::CompletionQueue* cq, void *tag);
}; };
}; };

@ -44,7 +44,7 @@ function main() {
} else { } else {
user = 'world'; user = 'world';
} }
client.sayHello({name: user}, function(err, response) { client.SayHello({name: user}, function(err, response) {
console.log('Greeting:', response.message); console.log('Greeting:', response.message);
}); });
} }

@ -39,9 +39,9 @@ var hello_proto = grpc.load(PROTO_PATH).helloworld;
var Server = grpc.buildServer([hello_proto.Greeter.service]); var Server = grpc.buildServer([hello_proto.Greeter.service]);
/** /**
* Implements the sayHello RPC method. * Implements the SayHello RPC method.
*/ */
function sayHello(call, callback) { function SayHello(call, callback) {
callback(null, {message: 'Hello ' + call.request.name}); callback(null, {message: 'Hello ' + call.request.name});
} }
@ -52,7 +52,7 @@ function sayHello(call, callback) {
function main() { function main() {
var server = new Server({ var server = new Server({
"helloworld.Greeter": { "helloworld.Greeter": {
sayHello: sayHello SayHello: SayHello
} }
}); });

@ -36,7 +36,7 @@ package helloworld;
// The greeting service definition. // The greeting service definition.
service Greeter { service Greeter {
// Sends a greeting // Sends a greeting
rpc sayHello (HelloRequest) returns (HelloReply) {} rpc SayHello (HelloRequest) returns (HelloReply) {}
} }
// The request message containing the user's name. // The request message containing the user's name.

@ -36,7 +36,7 @@ package helloworld;
// The greeting service definition. // The greeting service definition.
service Greeter { service Greeter {
// Sends a greeting // Sends a greeting
rpc sayHello (HelloRequest) returns (HelloReply) {} rpc SayHello (HelloRequest) returns (HelloReply) {}
} }
// The request message containing the user's name. // The request message containing the user's name.

@ -42,7 +42,7 @@ require 'helloworld_services'
# GreeterServer is simple server that implements the Helloworld Greeter server. # GreeterServer is simple server that implements the Helloworld Greeter server.
class GreeterServer < Helloworld::Greeter::Service class GreeterServer < Helloworld::Greeter::Service
# say_hello implements the sayHello rpc method. # say_hello implements the SayHello rpc method.
def say_hello(hello_req, _unused_call) def say_hello(hello_req, _unused_call)
Helloworld::HelloReply.new(message: "Hello #{hello_req.name}") Helloworld::HelloReply.new(message: "Hello #{hello_req.name}")
end end

@ -16,7 +16,7 @@ module Helloworld
self.unmarshal_class_method = :decode self.unmarshal_class_method = :decode
self.service_name = 'helloworld.Greeter' self.service_name = 'helloworld.Greeter'
rpc :sayHello, HelloRequest, HelloReply rpc :SayHello, HelloRequest, HelloReply
end end
Stub = Service.rpc_stub_class Stub = Service.rpc_stub_class

Loading…
Cancel
Save