Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

En/graceful shutdown config #1529

Open
wants to merge 17 commits into
base: development
Choose a base branch
from

Conversation

Umang01-hash
Copy link
Member

@Umang01-hash Umang01-hash commented Feb 26, 2025

Pull Request Template

Description:

Checklist:

  • I have formatted my code using goimport and golangci-lint.
  • All new code is covered by unit tests.
  • This PR does not decrease the overall code coverage.
  • I have reviewed the code comments and documentation for clarity.

Thank you for your contribution!

// Goroutine to handle shutdown when context is canceled
go func() {
<-ctx.Done()

// Create a shutdown context with a timeout
shutdownCtx, done := context.WithTimeout(context.WithoutCancel(ctx), shutDownTimeout)
shutdownCtx, done := context.WithTimeout(context.Background(), timeout)
Copy link
Member

Choose a reason for hiding this comment

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

why did we change the context?

Copy link
Member Author

Choose a reason for hiding this comment

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

In the original code, context.WithoutCancel was used to ensure the shutdown process had a fixed timeout (shutDownTimeout) to complete before termination.

In the updated code, the getShutdownTimeoutFromConfig function fetches the shutdown timeout from the configuration, allowing it to be configurable.

If context.WithCancel were used instead, the shutdown context would be canceled when the parent context is canceled, potentially cutting short the shutdown process and not respecting the full timeout value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Complete inflight requests after SIGTERM
3 participants