Distributed Transactions in Go: Read Before You Try
In the previous post, I looked into running transactions in a layered architecture. Now, let’s consider transactions that need to span more than one service. If you work with microservices, a time may come when you need a transaction running across them. Especially if the way they are split was an afterthought (the unfortunate but likely scenario). Service A calls service B, which calls service C, and if something goes wrong at the end, the system becomes inconsistent.
Database Transactions in Go with Layered Architecture
As I join a new company, I often feel like an impostor. After all the interviews, they really seem to know what they’re doing. I’m humbled and ready to learn from the best. On one such occasion, a few days in, I dealt with a production outage and asked the most senior engineer for help. They came to the rescue and casually flipped a value in the database with a manual update.
Using MySQL as a Pub/Sub
If you compare MySQL or PostgreSQL with Kafka or RabbitMQ, at first, it seems they are entirely different software. And usually, that’s true, as you would use them for quite different tasks. What they have in common is processing streams of data, and they specialize in specific ways of doing it. While Kafka and RabbitMQ are popular examples of Pub/Subs (also known as message queues or stream processing platforms), I’d like to share some patterns for using SQL databases as Pub/Subs as well.
Popular
- The Go libraries that never failed us: 22 libraries you need to know
- Safer Enums in Go
- Common Anti-Patterns in Go Web Applications
- How to implement Clean Architecture in Go (Golang)
- The Repository pattern in Go: a painless way to simplify your service logic
- Introduction to DDD Lite: When microservices in Go are not enough
Tags
- golang
- go
- watermill
- ddd
- domain-driven design
- events
- web-applications
- anti-patterns
- clean architecture
- ci
- firestore
- cloudrun
- gcloud
- googlecloud
- serverless
- testing
- advanced
- databases
- devops
- event-driven
- firebase
- gitlab
- microservices
- reactive
- repository
- architecture
- basics
- building-business-applications
- cqrs
- kafka
- mysql
- nats
- pipelines
- scalability
- transactions
- amqp
- authentication
- backend
- bounded-context
- c4
- cicd
- design-patterns
- diagrams
- docker
- dry
- e-book
- enums
- event-storming
- frameworks
- gamedev
- generics
- google-cloud
- grpc
- htmx
- intermediate
- javascript
- libraries
- maintainability
- metrics
- monolith
- openapi
- parallelism
- prometheus
- python
- rabbitmq
- security
- software-architecture
- sql
- sse
- strategic-ddd
- swagger
- terraform
- tips
- versioning