Skip to content

chore(context): refactoring the base of the context for the app#39

Merged
Jacobbrewer1 merged 4 commits intomainfrom
chore/ctx-notify
Apr 17, 2025
Merged

chore(context): refactoring the base of the context for the app#39
Jacobbrewer1 merged 4 commits intomainfrom
chore/ctx-notify

Conversation

@Jacobbrewer1
Copy link
Owner

@Jacobbrewer1 Jacobbrewer1 commented Apr 17, 2025

Describe your changes

This pull request refactors how interrupt signal handling is implemented by replacing the GetInterruptedContext function with a new CoreContext function. The changes simplify the codebase by consolidating functionality and removing unnecessary dependencies.

Refactoring of context handling:

  • app.go: Replaced the call to utils.GetInterruptedContext with CoreContext, simplifying the context initialization process.
  • context.go: Introduced a new CoreContext function in the web package, 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 the GetInterruptedContext function and its associated imports, as its functionality has been replaced by CoreContext. This reduces redundancy and dependencies on the utils package.

@Jacobbrewer1 Jacobbrewer1 marked this pull request as ready for review April 17, 2025 14:27
@Jacobbrewer1 Jacobbrewer1 enabled auto-merge (squash) April 17, 2025 14:27
@Jacobbrewer1 Jacobbrewer1 requested a review from Copilot April 17, 2025 14:27
@Jacobbrewer1 Jacobbrewer1 disabled auto-merge April 17, 2025 14:27
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) {

@Jacobbrewer1 Jacobbrewer1 enabled auto-merge (squash) April 17, 2025 14:28
@Jacobbrewer1 Jacobbrewer1 disabled auto-merge April 17, 2025 14:28
@Jacobbrewer1 Jacobbrewer1 requested a review from Copilot April 17, 2025 14:29
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@Jacobbrewer1 Jacobbrewer1 enabled auto-merge (squash) April 17, 2025 14:30
@Jacobbrewer1 Jacobbrewer1 merged commit 83c508b into main Apr 17, 2025
5 checks passed
@Jacobbrewer1 Jacobbrewer1 deleted the chore/ctx-notify branch April 17, 2025 14:30
@github-actions
Copy link

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.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 18, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants