This is a demo application that implements an asynchronous calculator. It consts of a "controller" microservice that handles connect-go (gRPC) requests and a "worker" microservice that is implemented as a google cloud function. The controller microservice schedules work to the worker microservice via google Pubsub. The worker microservice receives a calculation request via pubsub, performs the calculation and returns the response back to the controller via pubsub. The controller them stores the result to a Cloud SQL postgres database.
This demo shows how to use OpenTelemetry in a Go application that is running on GCP. It demonstrates the usage of middleware to seamlessly propagate context across services and how to use the OpenTelemetry SDK to create custom spans. It implements a middleware for google Pubsub that transfers the trace context in the message metadata.
Talk: https://www.youtube.com/watch?v=5rjTdA6BM1E
You can find the slides for this talk here
flowchart TD
CUSTOMER[Customer] ==>|1. Calculate expression| CONTROLLER(Controller)
CONTROLLER --> |2. Store scheduled calculation with UUID| DB_STORE[(CloudSQL)]
CONTROLLER -.-> |3. Queue Work| PUBSUB([Pubsub])
PUBSUB -.-> |4. Get work| MATH(Math Cloud Function)
MATH --> |5. Calculate| MATH
MATH -.-> |6. Calculation Result|PUBSUB
PUBSUB -.-> |7. Result ready| CONTROLLER
CONTROLLER ---> |8. Save result| DB_STORE
- RPC requests are recieved by the controller microservice using the connect protocol.
- It implements the
Calculate
and theList
methods.
- It implements the
- The controller stores the request in postgres using Gorm package
- The controller scheduled calculation using the Pubsub library.
- The math worker is implemented as a GCP Cloud Function. It receives the calculation request via Pubsub and returns the result via Pubsub.
- The controller receives the result via Pubsub and stores it in postgres.