Our great sponsors
-
WorkOS
The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.
-
sarama
Discontinued Sarama is a Go library for Apache Kafka. [Moved to: https://github.com/IBM/sarama]
This article about tries to implement of clean architecture microservice using: 🚀 Kafka as messages broker gRPC Go implementation of gRPC MongoDB as database Jaeger open source, end-to-end distributed tracing Prometheus monitoring and alerting Grafana for to compose observability dashboards with everything from Prometheus
On top layer of our app handling, logging errors and process metrics for Prometheus. Repository with the source code and list of all used tools u can find here 👨💻 :) I hope this article is usefully and helpfully, I'll be happy to receive any feedbacks or questions :)
Good kafka docker setup with enclouded UI is confluent, but it's had huge images size and will download a half of world wide internet to your local pc.🤖 For this reason here as UI client i used kafdrop
For Go client in production usually used segmentio and sarama, both is good and up to you which one to chose, for this project i used segmentio. I didn't implement any interesting business logic here and didn't cover tests, because of not enough time at this moment. Our microservice can communicate by kafka, gRPC and REST.
Workers validate message body then call usecase, if it's returns error, try for retry, good library for retry is retry-go, if again fails, publish error message to very simple Dead Letter Queue as i said, didn't implement here any interesting business logic, so in real production we have to handle error cases in the better way. And after message success processed commit it.
and REST API handler using echo: