Context
The codebase has several code quality problems that should be addressed to bring it up to modern Go standards and make it production-ready for Kubernetes environments.
Problems
No Graceful Shutdown
The main loop runs forever with no signal handling. There is no way to catch SIGTERM/SIGINT for clean shutdown, cancel in-flight operations, or log shutdown events. This is problematic in Kubernetes where pods receive SIGTERM before being killed.
Global Mutable State Without Synchronization
numaMap (package-level map) is read and written without mutex protection
config (package-level var) is similarly unprotected
- While currently single-goroutine, this is fragile and prevents future concurrency (e.g., adding an HTTP health endpoint)
Hardcoded Strings
- Environment variable names like
MY_NODE_NAME are used as magic strings in multiple files
Tasks
- Implement graceful shutdown with
signal.NotifyContext and context propagation
- Add
sync.RWMutex protection for package-level mutable state
- Extract hardcoded strings into package-level constants
- Improve error messages for missing configuration
Acceptance Criteria
- Binary handles SIGTERM gracefully (logs shutdown, flushes, exits cleanly)
- No data races detected by
go test -race ./...
golangci-lint run ./... passes with zero issues
Priority
Medium — important for production Kubernetes deployments where pods receive SIGTERM during rolling updates, node drains, and scaling events.
Context
The codebase has several code quality problems that should be addressed to bring it up to modern Go standards and make it production-ready for Kubernetes environments.
Problems
No Graceful Shutdown
The main loop runs forever with no signal handling. There is no way to catch SIGTERM/SIGINT for clean shutdown, cancel in-flight operations, or log shutdown events. This is problematic in Kubernetes where pods receive SIGTERM before being killed.
Global Mutable State Without Synchronization
numaMap(package-level map) is read and written without mutex protectionconfig(package-level var) is similarly unprotectedHardcoded Strings
MY_NODE_NAMEare used as magic strings in multiple filesTasks
signal.NotifyContextand context propagationsync.RWMutexprotection for package-level mutable stateAcceptance Criteria
go test -race ./...golangci-lint run ./...passes with zero issuesPriority
Medium — important for production Kubernetes deployments where pods receive SIGTERM during rolling updates, node drains, and scaling events.