From 2b0e3e9ff9f08b00aed2268853208a6b9926695b Mon Sep 17 00:00:00 2001 From: Paul Grosu Date: Tue, 6 Dec 2016 18:47:16 -0500 Subject: submit --- chapter/1/gRPC.md | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'chapter/1') 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 { Figure 3: Protocol Buffer version 2.0 representing a message data-structure.

-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 "Hi". +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 "Hi". 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 %}.


Table 1: Tag values for Protocol Buffer types.

+One will notice that there is a number associated with each field element in the Protocol Buffer definition, which represents its tag. 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 type and the rest the tag. 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 -- cgit v1.2.3