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

QGB e2e use signaling channel to notify #522

Closed
Tracked by #301
rach-id opened this issue Jul 5, 2022 · 2 comments
Closed
Tracked by #301

QGB e2e use signaling channel to notify #522

rach-id opened this issue Jul 5, 2022 · 2 comments
Assignees

Comments

@rach-id
Copy link
Member

rach-id commented Jul 5, 2022

Currently, the QGB is using context extensively to communicate. This can be improved via the use of a signaling channel.
This PR is an example of how to do it: #512 in here:

func trapSignal(logger tmlog.Logger, cancel context.CancelFunc) {
var sigCh = make(chan os.Signal, 1)
signal.Notify(sigCh, syscall.SIGTERM)
signal.Notify(sigCh, syscall.SIGINT)
sig := <-sigCh
logger.Info("caught signal; shutting down...", "signal", sig.String())
cancel()
}

@evan-forbes
Copy link
Member

Currently, the QGB is using context extensively to communicate.

mind elaborating on this a bit? is this referencing our reliance on ctx.Done()?

@rach-id
Copy link
Member Author

rach-id commented Jul 10, 2022

Yes, exactly. We have multiple functions waiting for a signal to stop processing. Currently, we're forced to use context timeouts and cancells in a complex way to notify all threads. However, we can use an easier mechanism using a special notify channel that can be used to trap any error or exit signal and notify everything to stop.

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

No branches or pull requests

2 participants