-
-
Notifications
You must be signed in to change notification settings - Fork 308
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
Add AfterJobRunsWithPanic
#733
Add AfterJobRunsWithPanic
#733
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hey @trungdlp-wolffun thanks for working on this!
I think the concept would fit nicely as another EventListener. EventListeners can be added to a single Job using WithEventListeners, as well as for the entire scheduler using WithGlobalJobOptions.
You could model it after AfterJobRunsWithError, but call it AfterJobRunsWithPanic
.
AfterJobRunsWithPanic
@JohnRoesler I changed it to the EventListener: AfterJobRunsWithPanic, you can review it now |
_ = callJobFuncWithParams(j.afterJobRunsWithPanic, j.id, j.name, recoverData) | ||
|
||
// if panic is occurred, we should return an error | ||
err = ErrPanicRecovered |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this error ever readable by the caller? Seems ineffectual. But I could be wrong 😁
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The caller can catch this error via an EventListener
WithEventListeners(
AfterJobRunsWithError(
func(jobID uuid.UUID, jobName string, err error) {
if errors.Is(err, gocron.ErrPanicRecovered) {
// ....
}
},
),
),
What does this do?
Which issue(s) does this PR fix/relate to?
Resolves #732
List any changes that modify/break current functionality
Have you included tests for your changes?
Yes
Did you document any new/modified functionality?
example_test.go
README.md
Notes