chore(context): refactoring the base of the context for the app#39
chore(context): refactoring the base of the context for the app#39Jacobbrewer1 merged 4 commits intomainfrom
Conversation
There was a problem hiding this comment.
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
Comments suppressed due to low confidence (1)
context.go:11
- [nitpick] Consider declaring CoreContext as a named function (e.g., 'func CoreContext() (context.Context, context.CancelFunc)') instead of assigning an anonymous function to a variable. This may improve clarity and consistency in the codebase.
var CoreContext = func() (context.Context, context.CancelFunc) {
There was a problem hiding this comment.
Pull Request Overview
This PR refactors the context handling mechanism by replacing the redundant GetInterruptedContext function with a consolidated CoreContext function. Key changes include:
- Removing the GetInterruptedContext function from utils/context.go.
- Introducing the CoreContext function in context.go to handle interrupt signals.
- Updating app.go to use CoreContext for context initialization.
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| utils/context.go | Removed obsolete GetInterruptedContext to eliminate unnecessary dependencies |
| context.go | Added CoreContext function that uses signal.NotifyContext for interrupt handling |
| app.go | Refactored context initialization to use the new CoreContext function |
|
I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. |
Describe your changes
This pull request refactors how interrupt signal handling is implemented by replacing the
GetInterruptedContextfunction with a newCoreContextfunction. The changes simplify the codebase by consolidating functionality and removing unnecessary dependencies.Refactoring of context handling:
app.go: Replaced the call toutils.GetInterruptedContextwithCoreContext, simplifying the context initialization process.context.go: Introduced a newCoreContextfunction in thewebpackage, which provides a context that is canceled on receiving an interrupt signal. This implementation is more concise and eliminates the need for additional logging within the function. In addition to this, we have one less thread running per instance.Code cleanup:
utils/context.go: Removed theGetInterruptedContextfunction and its associated imports, as its functionality has been replaced byCoreContext. This reduces redundancy and dependencies on theutilspackage.