/grpc-up-and-running

The study note of the book "gRPC: Up and Running (Kasun Indrasiri)" and the reconstruction of source code.

Primary LanguageGoApache License 2.0Apache-2.0

grpc-up-and-running

License

The study note of the book "gRPC: Up and Running (Kasun Indrasiri)" and the reconstruction of source code.

Study Notes

Experience

Directory Structure

  • docs: The study notes of this books
    • diagram: The diagrams for this repository.
  • examples: The example code of gRPC sub-techniques.
    • loadbalancing: The load balancer for multiple gRPC services.
    • security: The example of the authentication solutions for gRPC.
      • one-way-tls: The one-way TLS authentication.
      • two-way-tls: The two-way (mTLS) authentication.
      • basic-auth: The basic authentication.
      • oauth2: The OAuth 2 authentication.
      • jwt: The JWT authentication.
    • grpc-gateway: The gRPC gateway example.
  • imgs: The images for this repository.
  • productinfo: The hello-world example of gRPC.
  • ordermgt: The gRPC examples for demostrating 4 gRPC communication patterns.

Differences to The Original Source Code

  • Add the detailed instruction about how to install protocol buffer compiler.
  • Add tutorials of writing server code and client code and modularize them by functionality.
  • Flatten the source code by chapter into one application.
  • Make sure the code is runnable (Fix some issues in the original source code).
  • Better documentation.
  • Add comments to make the code easy to read.

Services And Remote Methods

Product Info

Method Pattern Description
AddProduct Unary RPC Add a product.
GetProduct Unary RPC Get a product by product ID.

Order Management

Method Pattern Description
AddOrder Unary RPC Add a new order.
GetOrder Unary RPC Get a order by order ID.
SearchOrders Server-side streaming Get all the orders which has a certain item.
UpdateOrders Client-side streaming Update multiple orders.
ProcessOrders Bidirectional streaming Process multiple orders.
  • All the order IDs will be sent from client as a stream.
  • A combined shipment will contains all the orders which will be delivered to the same destination.
  • When the max batch size is reached, all the currently created combined shipments will be sent back to the client.