chore: gracefully exit on REST server shutdown #59
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request refactors the server startup and shutdown logic for the
otlpinfservice to improve error handling and resource management. The main change is switching the startup method to return an error channel, allowing asynchronous error reporting and cleaner shutdown procedures. The tests have also been updated to accommodate this new pattern and ensure proper cleanup.Server startup and shutdown improvements:
OltpInf.Startto return a channel of errors instead of a single error, enabling asynchronous error handling and reporting during server startup and runtime. (otlpinf/otlpinf.go,cmd/main.go) [1] [2]OltpInf.Stopto gracefully shut down the HTTP server and clean up temporary resources, ensuring all resources are properly released. (otlpinf/otlpinf.go)startServerto use Go'shttp.Serverfor better control over server lifecycle and error propagation, replacing the previous synchronous start logic. (otlpinf/server.go)Testing improvements:
Start, adding proper cleanup logic and error assertions to verify server startup and shutdown behavior. (otlpinf/otlpinf_test.go) [1] [2] [3]t.Cleanupand ensuring all server errors are logged and handled. (otlpinf/otlpinf_test.go) [1] [2]Minor code improvements:
otlpinf/otlpinf.go,otlpinf/server.go,otlpinf/otlpinf_test.go) [1] [2] [3]