Skip to content

Commit f57b1bf

Browse files
authored
Merge pull request grpc#213 from jtattermusch/csharp_client_vs_stub
Fix confusion caused by terms "client" and "stub".
2 parents f27f0ee + ee223fb commit f57b1bf

File tree

3 files changed

+17
-19
lines changed

3 files changed

+17
-19
lines changed

docs/guides/concepts.md

+4-5
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,8 @@ We'll look at the different types of RPC in more detail in the RPC life cycle se
6666

6767
Starting from a service definition in a .proto file, gRPC provides protocol buffer compiler plugins that generate client- and server-side code. gRPC users typically call these APIs on the client side and implement the corresponding API on the server side.
6868

69-
- On the server side, the server implements the service interface and runs a gRPC server to handle client calls. The gRPC infrastructure decodes incoming requests, executes service methods, and encodes service responses.
70-
- On the client side, the client has a *stub* that implements exactly the same methods as the server. The client can then just call those methods on the local stub, wrapping the parameters in the appropriate protocol buffer message type — gRPC looks after sending the request(s) to the server and returning the server's protocol buffer response(s).
71-
69+
- On the server side, the server implements the methods declared by the service and runs a gRPC server to handle client calls. The gRPC infrastructure decodes incoming requests, executes service methods, and encodes service responses.
70+
- On the client side, the client has a local object known as *stub* (for some languages, the preferred term is *client*) that implements the same methods as the service. The client can then just call those methods on the local object, wrapping the parameters for the call in the appropriate protocol buffer message type - gRPC looks after sending the request(s) to the server and returning the server's protocol buffer response(s).
7271

7372
### Synchronous vs. asynchronous
7473

@@ -84,7 +83,7 @@ Now let's take a closer look at what happens when a gRPC client calls a gRPC ser
8483

8584
First let's look at the simplest type of RPC, where the client sends a single request and gets back a single response.
8685

87-
- Once the client calls the method on the stub, the server is notified that the RPC has been invoked with the client's [metadata](#metadata) for this call, the method name, and the specified [deadline](#deadlines) if applicable.
86+
- Once the client calls the method on the stub/client object, the server is notified that the RPC has been invoked with the client's [metadata](#metadata) for this call, the method name, and the specified [deadline](#deadlines) if applicable.
8887
- The server can then either send back its own initial metadata (which must be sent before any response) straight away, or wait for the client's request message - which happens first is application-specific.
8988
- Once the server has the client's request message, it does whatever work is necessary to create and populate its response. The response is then returned (if successful) to the client together with status details (status code and optional status message) and optional trailing metadata.
9089
- If the status is OK, the client then gets the response, which completes the call on the client side.
@@ -136,7 +135,7 @@ TBD
136135

137136
### Channels
138137

139-
A gRPC channel provides a connection to a gRPC server on a specified host and port and is used when creating a client stub. Clients can specify channel arguments to modify gRPC's default behaviour, such as switching on and off message compression. A channel has state, including <code>connected</code> and <code>idle</code>.
138+
A gRPC channel provides a connection to a gRPC server on a specified host and port and is used when creating a client stub (or just "client" in some languages). Clients can specify channel arguments to modify gRPC's default behaviour, such as switching on and off message compression. A channel has state, including <code>connected</code> and <code>idle</code>.
140139

141140
How gRPC deals with closing down channels is language-dependent. Some languages also permit querying channel state.
142141

docs/index.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ services. As in many RPC systems, gRPC is based around the idea of defining
4242
a *service*, specifying the methods that can be called remotely with their
4343
parameters and return types. On the server side, the server implements this
4444
interface and runs a gRPC server to handle client calls. On the client side,
45-
the client has a *stub* that provides exactly the same methods as the server.
45+
the client has a *stub* (referred to as just *client* in some languages)
46+
that provides the same methods as the server.
4647

4748
<img src="../img/grpc_concept_diagram_00.png" class="img-responsive" alt="gRPC diagram">
4849

@@ -436,8 +437,8 @@ As you can see, a gRPC method can accept only a single protocol buffer message t
436437
Once we've defined our service, we use the protocol buffer compiler
437438
`protoc` to generate the special client and server code we need to create
438439
our application - you
439-
can generate gRPC code in any gRPC-supported language, although PHP and Objective-C only support creating clients. The generated code contains both stub code for clients to
440-
use and an abstract interface for servers to implement, both with the method
440+
can generate gRPC code in any gRPC-supported language, although PHP and Objective-C only support creating clients. The generated code contains both client-side code for clients to
441+
call into and an abstract interface for servers to implement, both with the method
441442
defined in our `Greeter` service.
442443

443444
(If you didn't install the gRPC plugins and protoc on your system and are just reading along with
@@ -577,9 +578,8 @@ To generate the code, run the following command from the `examples/csharp/hellow
577578

578579
Running the appropriate command for your OS regenerates the following files in the Greeter directory:
579580

580-
- `Greeter/Helloworld.cs` defines a namespace `Helloworld`
581-
- This contains all the protocol buffer code to populate, serialize, and retrieve our request and response message types
582-
- `Greeter/HelloworldGrpc.cs`, provides stub and service classes, including:
581+
- `Greeter/Helloworld.cs` contains all the protocol buffer code to populate, serialize, and retrieve our request and response message types
582+
- `Greeter/HelloworldGrpc.cs` provides generated client and server classes, including:
583583
- an abstract base class `Greeter.GreeterBase` to inherit from when defining RouteGuide service implementations
584584
- a class `Greeter.GreeterClient` that can be used to access remote RouteGuide instances
585585

@@ -947,7 +947,7 @@ we'll leave that for the tutorial.
947947

948948
First let's look at how we connect to the `Greeter` server. First we need
949949
to create a gRPC channel, specifying the hostname and port of the server we
950-
want to connect to. Then we use the channel to construct the stub instance.
950+
want to connect to. Then we use the channel to construct the client stub instance.
951951

952952

953953
<div class="tabs">
@@ -1077,7 +1077,7 @@ In PHP, we can do this in a single step using the `GreeterClient` class's constr
10771077
Now we can contact the service and obtain a greeting:
10781078

10791079
1. We construct and fill in a `HelloRequest` to send to the service.
1080-
2. We call the stub's `SayHello()` RPC with our request and get a populated `HelloReply` if the RPC is successful, from which we can get our greeting.
1080+
2. We call the client stub's `SayHello()` RPC with our request and get a populated `HelloReply` if the RPC is successful, from which we can get our greeting.
10811081

10821082
<div class="tabs">
10831083
<ul>

docs/tutorials/basic/csharp.md

+5-6
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ service RouteGuide {
5252

5353
Then you define `rpc` methods inside your service definition, specifying their request and response types. gRPC lets you define four kinds of service method, all of which are used in the `RouteGuide` service:
5454

55-
- A *simple RPC* where the client sends a request to the server using the stub and waits for a response to come back, just like a normal function call.
55+
- A *simple RPC* where the client sends a request to the server using the client object and waits for a response to come back, just like a normal function call.
5656

5757
```protobuf
5858
// Obtains the feature at a given position.
@@ -123,9 +123,8 @@ To generate the code, the following command should be run from the `examples/csh
123123

124124
Running the appropriate command for your OS regenerates the following files in the RouteGuide directory:
125125

126-
- `RouteGuide/RouteGuide.cs` defines a namespace `Routeguide`
127-
- This contains all the protocol buffer code to populate, serialize, and retrieve our request and response message types
128-
- `RouteGuide/RouteGuideGrpc.cs`, provides stub and service classes
126+
- `RouteGuide/RouteGuide.cs` contains all the protocol buffer code to populate, serialize, and retrieve our request and response message types
127+
- `RouteGuide/RouteGuideGrpc.cs` provides generated client and server classes, including:
129128
- an abstract class `RouteGuide.RouteGuideBase` to inherit from when defining RouteGuide service implementations
130129
- a class `RouteGuide.RouteGuideClient` that can be used to access remote RouteGuide instances
131130

@@ -284,9 +283,9 @@ As you can see, we build and start our server using `Grpc.Core.Server` class. To
284283

285284
In this section, we'll look at creating a C# client for our `RouteGuide` service. You can see our complete example client code in [examples/csharp/route_guide/RouteGuideClient/Program.cs](https://github.com/grpc/grpc/blob/{{ site.data.config.grpc_release_branch }}/examples/csharp/route_guide/RouteGuideClient/Program.cs).
286285

287-
### Creating a stub
286+
### Creating a client object
288287

289-
To call service methods, we first need to create a *stub*.
288+
To call service methods, we first need to create a client object (also referred to as *stub* for other gRPC languages).
290289

291290
First, we need to create a gRPC client channel that will connect to gRPC server. Then, we create an instance of the `RouteGuite.RouteGuideClient` class generated from our .proto, passing the channel as an argument.
292291

0 commit comments

Comments
 (0)