Assessments

You'll find the answers to the questions in all chapters of the book in this section.

Chapter 1, Creating a Basic gRPC Application on ASP.NET Core

  1. B. "You cannot have a Protobuf message definition without any fields" is an incorrect statement. You can have empty message definitions in Protobuf.
  2. A. ASP.NET Core is a cross-platform framework that works on Windows, Linux, and macOS, so gRPC can be implemented on them.
  3. C. You need to register each proto file by adding a Proto element to your project file. Then, you can specify the GrpcServices attribute inside it, which can be set to Server, Client, or Both. It's set to Both by default, so if you don't specify this attribute, both client and the server code will be generated. If you specify Server, only the server code will be generated. So, either Both or Server is a valid option for generating server code.
  4. C. To get gRPC to work inside an ASP.NET Core server app, you need to add all the required references to the project. Then, for each gRPC service definition, you need to create a C# class that overrides from a class that was auto-generated from a proto file, representing one of its service definitions. Then, you need to register gRPC capabilities inside the Startup class. Finally, you need to register your custom C# implementation of a gRPC service as an endpoint in your middleware.
  5. C. The client-side code that's generated with both the synchronous and asynchronous versions of each RPC is defined in a proto file. The name of the synchronous function is the same as the one defined in the proto file. The asynchronous version has the same name but with Async at the end.

Chapter 2, When gRPC Is the Best Tool and When It Isn't

  1. B. Yes, by utilizing streaming
  2. C. Yes, but only by using async/await on the client
  3. A. Server-streaming calls
  4. B. Yes, both on the server and the client
  5. D. Calls from the server to the client without a request from the client

Chapter 3, Protobuf – the Communication Protocol of gRPC

  1. A. long.
  2. A. The int32 data type will have only as many bytes allocated as necessary, while fixed32 always occupies 4 bytes.
  3. C. Create a repeated field of a message that itself has a repeated field.
  4. B. The original field gets unset, and the new field gets set.
  5. D. You can keep the original Proto file that is specified in the import directive but get it to import the new proto file via the import public directive.

Chapter 4, Performance Best Practices for Using gRPC on .NET

  1. B. Channel.
  2. C. 100.
  3. A. Apply the stream keyword before the rpc keyword.
  4. D. Apply the stream keyword before both the input and output parameters.
  5. A. When you intend to modify the original byte array after this call.

Chapter 5, Applying Versioning to the gRPC API

  1. C. It will not affect the functionality.
  2. B. sfixed32 and int32.
  3. A. It will be populated with the default value on the client.
  4. D. Use the reserved keyword, followed by the sequence numbers of the removed fields.
  5. C. Using separate Protobuf definitions for separate API versions.

Chapter 6, Scaling a gRPC Application

  1. C. To split a large number of requests between multiple instances of the application.
  2. C. By getting the list of individual endpoint addresses and calling them directly.
  3. D. All of the above.
  4. A. The client connects to the proxy endpoint and the proxy redirects it to individual application instances.
  5. C. Support for HTTP/2.

Chapter 7, Using Different Call Types Supported by gRPC

  1. B. Yes
  2. C. Only when you make asynchronous calls
  3. A. Unknown
  4. C. To set a strict timeout on the call's completion time
  5. D. By using the stream keyword between the request and response message definitions

Chapter 8, Using Well-Known Types to Make Protobuf More Handy

  1. C. google/protobuf/wrappers.proto.
  2. C. Fixed64Value.
  3. A. Duration is equivalent to DateTimeOffset.
  4. D. All of the above.
  5. C. The Any data type cannot store strings.

Chapter 9, Securing gRPC Endpoints in Your ASP.NET Core Application with SSL/TLS

  1. B. TLS.
  2. C. With this configuration, insecure requests are routed to HTTP/1.1.
  3. D. All of the above.
  4. D. A .pfx file stores the complete certificate chain, while a .crt file only stores the public key and any related metadata.
  5. A. For authentication.

Chapter 10, Applying Authentication and Authorization to gRPC Endpoints

  1. B. To ensure that the user is who they claim to be.
  2. A. To ensure that only users with specific permissions can access the application.
  3. C. OpenID Connect is used for authentication.
  4. C. Header, payload, and signature.
  5. B. Any JSON field in the payload.

Chapter 11, Using Logging, Metrics, and Debugging in gRPC on .NET

  1. C. You can set the EnableDetailedErrors option on the server.
  2. A. Set the Grpc entry in the logging settings to Debug.
  3. B. By checking if the exception is of the RpcException type.
  4. B. By adding the IloggerFactory implementation to the GrpcChannel options.
  5. B. Metrics consist of data that can be easily aggregated (counters, gauges, histograms, and so on), while logs provide detailed information about each event.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.137.218.215