-
-
Notifications
You must be signed in to change notification settings - Fork 103
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
feat(events): add events system #155
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This PR also re-orders some logic; I'm going to pull that out into a separate PR to keep this one cleaner. |
This was referenced Dec 4, 2020
Closed
this looks amazing, my only question above is how one would subscribe to the |
Great question @shicholas; does the above couple commits address this question sufficiently? |
yes, thanks! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
There's lots of events that happen inside of Graphile Worker that library consumers might be interested in; this PR raises these events with an event system.
IMPORTANT: people registering event handlers MUST make sure that these handlers do NOT throw errors. We've wrapped the
emit
with a try/catch that swallows the error in the two most dangerous places, but consumers must be certain that errors are not thrown as this may cause unexpected states of the work queue to take place.Events added so far:
pool:create
- When a worker pool is createdpool:listen:connecting
- When a worker pool attempts to connect to PG ready to issue a LISTEN statementpool:listen:success
- When a worker pool starts listening for jobs via PG LISTENpool:listen:error
- When a worker pool faces an error on their PG LISTEN clientpool:release
- When a worker pool is releasedpool:gracefulShutdown
- When a worker pool starts a graceful shutdownpool:gracefulShutdown:error
- When a worker pool graceful shutdown throws an errorworker:create
- When a worker is createdworker:release
- When release of a worker is requestedworker:stop
- When a worker stops (normally after a release)worker:getJob:error
- When a worker calls get_job but there are no available jobsworker:getJob:empty
- When a worker calls get_job but there are no available jobsworker:fatalError
- When a worker is createdjob:start
- When a job is retrieved by get_jobjob:success
- When a job completes successfullyjob:error
- When a job throws an errorjob:failed
- When a job fails permanently (emitted after job:error when appropriate)gracefulShutdown
- When the runner is terminated by a signalstop
- When the runner is stoppedFixes #28
Performance impact
There must be an impact, but it seems too small to show up in benchmarks.
Security impact
None known.