Menu

Post image 1
Post image 2
Post image 3
1 / 3
0

A Worker Pool That Actually Drains on Shutdown: A Pattern for Go Services

DEV Community·Gabriel Anhaia·29 days ago
#YOvMFRa7
Reading 0:00
15s threshold

Book: Hexagonal Architecture in Go Also by me: Thinking in Go (2-book series) — Complete Guide to Go Programming + Hexagonal Architecture in Go My project: Hermes IDE | GitHub — an IDE for developers who ship with Claude Code and other AI coding tools Me: xgabriel.com | GitHub A team I worked with ran a Go service that consumed a queue, did some computation per message, and wrote results back to Postgres. The shutdown code looked clean. Channel close, wg.Wait() , exit zero. They had an integration test that drained the queue and confirmed every message was processed. Then Kubernetes rolled the deployment. About one in fifty messages came back later with a duplicate-key error from Postgres. Some never came back at all. The integration test still passed. The on-call engineer spent a Saturday correlating pod-termination timestamps against message IDs before the shape became clear: every lost or duplicated message was in flight at the moment SIGTERM arrived. The clean shutdown path was fine.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.

Read More