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

fix: Better context handling and graceful shutdown #9

Merged
merged 1 commit into from
Nov 8, 2023

Conversation

snorremd
Copy link
Owner

@snorremd snorremd commented Nov 8, 2023

Use go contexts to handle shutting down go routines and closing channels. This largely makes the receiver pattern with the subscriber and firehose structs unecessary. Instead we pass the necessary arguments to the functions together with the context. The functions listen for the context to signal the process should close, so no separate shutdown function is necessary.

Fiber is handled as before.

The main.go main function now sets up a cancelable context and passes this to the urfave cli run command. A go routine listens for interrupts and if so gracefully signals to shutdown by calling cancel on the context.

Use go contexts to handle shutting down go routines and closing
channels. This largely makes the receiver pattern with the subscriber
and firehose structs unecessary. Instead we pass the necessary arguments
to the functions together with the context. The functions listen for the
context to signal the process should close, so no separate shutdown
function is necessary.

Fiber is handled as before.

The main.go main function now sets up a cancelable context and passes
this to the urfave cli run command. A go routine listens for interrupts
and if so gracefully signals to shutdown by calling cancel on the
context.
@snorremd snorremd merged commit ed95262 into main Nov 8, 2023
@snorremd snorremd deleted the fix/better-graceful-shutdown-context-cancel branch November 8, 2023 20:24
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.

1 participant