Enhance server with context initialization and graceful shutdown
- Added context-aware server initialization in cmd/server/main.go - Implemented graceful shutdown handling with SIGINT/SIGTERM signals - Added 30-second shutdown timeout for active connections - Updated Greet service to use context.Context as first parameter - Enhanced Zerolog integration with Trace level logging - Added context-aware logging in Greet function calls - Fixed route structure to use /api/v1/greet/* prefix - Updated all handlers and tests to use context - Comprehensive AGENTS.md documentation with verified commands - Added server context management architecture section - Updated API endpoint documentation with working examples Changes: - cmd/server/main.go: Complete rewrite with context and graceful shutdown - pkg/greet/greet.go: Added context parameter and trace logging - pkg/greet/api_v1.go: Updated interface and handlers for context - pkg/greet/greet_test.go: Updated tests to use context - cmd/greet/main.go: Updated CLI to use context - pkg/server/server.go: Trace level config and context logging - AGENTS.md: Comprehensive documentation update - go.mod/go.sum: Added Zerolog dependency All tests passing, server working with graceful shutdown verified.
This commit is contained in:
9
go.sum
9
go.sum
@@ -1,2 +1,11 @@
|
||||
github.com/go-chi/chi/v5 v5.2.5 h1:Eg4myHZBjyvJmAFjFvWgrqDTXFyOzjj7YIm3L3mu6Ug=
|
||||
github.com/go-chi/chi/v5 v5.2.5/go.mod h1:X7Gx4mteadT3eDOMTsXzmI4/rwUpOwBHLpAfupzFJP0=
|
||||
github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE=
|
||||
github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8=
|
||||
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
||||
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||
github.com/rs/zerolog v1.35.0 h1:VD0ykx7HMiMJytqINBsKcbLS+BJ4WYjz+05us+LRTdI=
|
||||
github.com/rs/zerolog v1.35.0/go.mod h1:EjML9kdfa/RMA7h/6z6pYmq1ykOuA8/mjWaEvGI+jcw=
|
||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.42.0 h1:omrd2nAlyT5ESRdCLYdm3+fMfNFE/+Rf4bDIQImRJeo=
|
||||
golang.org/x/sys v0.42.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
|
||||
|
||||
Reference in New Issue
Block a user