-
-
Notifications
You must be signed in to change notification settings - Fork 744
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
[FEATURE REQUEST] Is there any way to do some specific action before periodic task enqueue? #456
Comments
@ChihSeanHsu thank you for creating a feature request. What kind of action do you need to perform before enqueueing a task? I want to understand the motivation. |
@hibiken Thanks for your prompt response. |
I see. Actually, now that I'm thinking about it, maybe it makes sense to allow users to provide callbacks before and after enqueue happens on Scheduler. Something like: type SchedulerOpts struct {
// PreEnqueueFunc, if provided, is called before a task gets enqueued by Scheduler.
// The callback function should return quickly to not block the current thread.
PreEnqueueFunc func(task *Task, opts []Option)
// PostEnqueueFunc, if provided, is called after a task gets enqueued by Scheduler.
// The callback function should return quickly to not block the current thread.
PostEnqueueFunc func(info *TaskInfo, err error)
// ... other options
// Deprecated: Use PostEnqueueFunc instead
ErrorHandlerFunc func(task *Task, opts []Option, err error)
} |
@hibiken Great. |
@ChihSeanHsu Feel free to open a PR if you have bandwidth to work on it. Thanks :) |
Closed via #476. This feature will be included in the next release. Thank you @ChihSeanHsu ! |
Is your feature request related to a problem? Please describe.
As title, I'm wondering is there any option or handler before periodic task enqueue?
Describe the solution you'd like
Maybe, we can solve this case just like error-handling
Additional context
IMO, we can implement this function in Enqueue part, not only for periodic task.
The text was updated successfully, but these errors were encountered: