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

[FEATURE REQUEST] Is there any way to do some specific action before periodic task enqueue? #456

Closed
ChihSeanHsu opened this issue May 8, 2022 · 7 comments
Assignees
Labels
enhancement New feature or request

Comments

@ChihSeanHsu
Copy link
Contributor

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.

@ChihSeanHsu ChihSeanHsu added the enhancement New feature or request label May 8, 2022
@hibiken
Copy link
Owner

hibiken commented May 9, 2022

@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.

@ChihSeanHsu
Copy link
Contributor Author

@hibiken Thanks for your prompt response.
We want to have a metrics to monitor the periodic enqueue count or some other actions (Currently, I have no another idea).
Although, we can just make this metrics by processing task part, but I just wonder is there any pre-action way not post-action.

@hibiken
Copy link
Owner

hibiken commented May 10, 2022

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)
}

@ChihSeanHsu
Copy link
Contributor Author

@hibiken Great.
Thanks for your help!
What will the road map be about this small feature?
Or can I just submit a PR about it?

@hibiken
Copy link
Owner

hibiken commented May 10, 2022

@ChihSeanHsu Feel free to open a PR if you have bandwidth to work on it. Thanks :)

@ChihSeanHsu
Copy link
Contributor Author

Hi @hibiken
Here is the PR, and feel free to review it thanks.

@hibiken
Copy link
Owner

hibiken commented May 27, 2022

Closed via #476. This feature will be included in the next release. Thank you @ChihSeanHsu !

@hibiken hibiken closed this as completed May 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants