Merge pull request #168 from nicolasnoble/api-upgrade

API change - fixing old code and doc.
pull/3109/head
Eric Anderson 10 years ago
commit 8fa2c95b69
  1. 4
      cpp/cpptutorial.md
  2. 2
      cpp/helloworld/greeter_server.cc
  3. 2
      cpp/route_guide/route_guide_server.cc

@ -214,7 +214,7 @@ void RunServer(const std::string& db_path) {
RouteGuideImpl service(db_path); RouteGuideImpl service(db_path);
ServerBuilder builder; ServerBuilder builder;
builder.AddPort(server_address, grpc::InsecureServerCredentials()); builder.AddListeningPort(server_address, grpc::InsecureServerCredentials());
builder.RegisterService(&service); builder.RegisterService(&service);
std::unique_ptr<Server> server(builder.BuildAndStart()); std::unique_ptr<Server> server(builder.BuildAndStart());
std::cout << "Server listening on " << server_address << std::endl; std::cout << "Server listening on " << server_address << std::endl;
@ -225,7 +225,7 @@ As you can see, we build and start our server using a `ServerBuilder`. To do thi
1. Create an instance of our service implementation class `RouteGuideImpl`. 1. Create an instance of our service implementation class `RouteGuideImpl`.
2. Create an instance of the factory `ServerBuilder` class. 2. Create an instance of the factory `ServerBuilder` class.
3. Specify the address and port we want to use to listen for client requests using the builder's `AddPort()` method. 3. Specify the address and port we want to use to listen for client requests using the builder's `AddListeningPort()` method.
4. Register our service implementation with the builder. 4. Register our service implementation with the builder.
5. Call `BuildAndStart()` on the builder to create and start an RPC server for our service. 5. Call `BuildAndStart()` on the builder to create and start an RPC server for our service.
5. Call `Wait()` on the server to do a blocking wait until process is killed or `Shutdown()` is called. 5. Call `Wait()` on the server to do a blocking wait until process is killed or `Shutdown()` is called.

@ -65,7 +65,7 @@ void RunServer() {
GreeterServiceImpl service; GreeterServiceImpl service;
ServerBuilder builder; ServerBuilder builder;
builder.AddPort(server_address, grpc::InsecureServerCredentials()); builder.AddListeningPort(server_address, grpc::InsecureServerCredentials());
builder.RegisterService(&service); builder.RegisterService(&service);
std::unique_ptr<Server> server(builder.BuildAndStart()); std::unique_ptr<Server> server(builder.BuildAndStart());
std::cout << "Server listening on " << server_address << std::endl; std::cout << "Server listening on " << server_address << std::endl;

@ -187,7 +187,7 @@ void RunServer(const std::string& db_path) {
RouteGuideImpl service(db_path); RouteGuideImpl service(db_path);
ServerBuilder builder; ServerBuilder builder;
builder.AddPort(server_address, grpc::InsecureServerCredentials()); builder.AddListeningPort(server_address, grpc::InsecureServerCredentials());
builder.RegisterService(&service); builder.RegisterService(&service);
std::unique_ptr<Server> server(builder.BuildAndStart()); std::unique_ptr<Server> server(builder.BuildAndStart());
std::cout << "Server listening on " << server_address << std::endl; std::cout << "Server listening on " << server_address << std::endl;

Loading…
Cancel
Save