aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Grosu <pgrosu@gmail.com>2016-12-06 18:47:16 -0500
committerPaul Grosu <pgrosu@gmail.com>2016-12-06 18:47:16 -0500
commit2b0e3e9ff9f08b00aed2268853208a6b9926695b (patch)
tree31f86703efab6a5340079082418a92e220b34c6a
parente9d10f981f3e2d81f913bd59c4d797373c980f6d (diff)
submit
-rw-r--r--chapter/1/gRPC.md10
1 files changed, 8 insertions, 2 deletions
diff --git a/chapter/1/gRPC.md b/chapter/1/gRPC.md
index 62a3795..fb3c2a0 100644
--- a/chapter/1/gRPC.md
+++ b/chapter/1/gRPC.md
@@ -67,13 +67,19 @@ message Hello {
<em>Figure 3: Protocol Buffer version 2.0 representing a message data-structure.</em>
</p>
-This message will also be encoded for highest compression when sent over the wire. For example, let us say that the message is the string <em>"Hi"</em>.
+This message will also be encoded for highest compression when sent over the wire. For example, let us say that the message is the string <em>"Hi"</em>. Every Protocol Buffer type has a value, and in this case a string has a value of `2`, as noted in the Table 1 {% cite Protobuf-Types %}.
<p align="center">
<img src="figures/protobuf-types.png" /><br>
<em>Table 1: Tag values for Protocol Buffer types.</em>
</p>
+One will notice that there is a number associated with each field element in the Protocol Buffer definition, which represents its <em>tag</em>. In Figure 3, the field `name` has a tag of `1`. When a message gets encoded each field will start with a one byte value (8 bits), where the least-significant 3-bit value encode the <em>type</em> and the rest the <em>tag</em>. In this case tag which is `1`, with a type of 2. Thus the encoding will be `00001 010`, which has a hexdecimal value of `A`. The following byte is the length of the string which is `2`, followed by the string as `48` and `69` representing `H` and `i`. Thus the whole tranmission will look as follows:
+
+```
+A 2 48 69
+```
+
Thus the language had to be updated to support gRPC and the development of a service message with a request and a response definition was added for version version 3.0 of Protocol Buffers. The updated implementation would look as follows {% cite HelloWorldProto %}:
```
@@ -125,4 +131,4 @@ gRPC was built on top of HTTP/2, and we will cover the specifics of gRPC-Java, b
[Netty]: http://netty.io/
[RFC7540]: http://httpwg.org/specs/rfc7540.html
[HelloWorldProto]: https://github.com/grpc/grpc/blob/master/examples/protos/helloworld.proto
-
+[Protobuf-Types]: https://developers.google.com/protocol-buffers/docs/encoding