[GH-ISSUE #447] [FEATURE REQUEST] Expose an option to change standard cron parser for a scheduler #2231

Closed
opened 2026-03-15 19:46:54 +03:00 by kerem · 5 comments
Owner

Originally created by @SergeyNSW on GitHub (May 4, 2022).
Original GitHub issue: https://github.com/hibiken/asynq/issues/447

Originally assigned to: @hibiken on GitHub.

Is your feature request related to a problem? Please describe.
I'd like to have an ability to run a job every N seconds, the cron package used behind the scene allows to have extended (with seconds) or custom schedule parser, but the async uses default one.
Describe the solution you'd like
Is it possible to extend the asynq.SchedulerOpts so that it would accept custom cron.ScheduleParser and pass it as an option to the cron instance?
Thanks

Originally created by @SergeyNSW on GitHub (May 4, 2022). Original GitHub issue: https://github.com/hibiken/asynq/issues/447 Originally assigned to: @hibiken on GitHub. **Is your feature request related to a problem? Please describe.** I'd like to have an ability to run a job every N seconds, the cron package used behind the scene allows to have extended (with seconds) or custom schedule parser, but the async uses default one. **Describe the solution you'd like** Is it possible to extend the asynq.SchedulerOpts so that it would accept custom cron.ScheduleParser and pass it as an option to the cron instance? Thanks
kerem 2026-03-15 19:46:54 +03:00
Author
Owner

@hibiken commented on GitHub (May 10, 2022):

@SergeyNSW thank you for this issue!

It makes sense to me. We probably don't want to directly expose the cron.SchedulerParser since that would complicate the versioning, but since the SchedulerParser is defined with interfaces we can simply expose that same and pass it to cron package behind the scene. Let me work on this soon 👍

<!-- gh-comment-id:1122361047 --> @hibiken commented on GitHub (May 10, 2022): @SergeyNSW thank you for this issue! It makes sense to me. We probably don't want to directly expose the `cron.SchedulerParser` since that would complicate the versioning, but since the `SchedulerParser` is defined with interfaces we can simply expose that same and pass it to `cron` package behind the scene. Let me work on this soon 👍
Author
Owner

@SergeyNSW commented on GitHub (May 10, 2022):

Thank you, looking forward to this improvement.

On 10 May 2022, at 16:03, Ken Hibino @.***> wrote:

@SergeyNSW https://github.com/SergeyNSW thank you for this issue!

It makes sense to me. We probably don't want to directly expose the cron.SchedulerParser since that would complicate the versioning, but since the SchedulerParser is defined with interfaces we can simply expose that same and pass it to cron package behind the scene. Let me work on this soon 👍


Reply to this email directly, view it on GitHub https://github.com/hibiken/asynq/issues/447#issuecomment-1122361047, or unsubscribe https://github.com/notifications/unsubscribe-auth/AVODLEFCYNWO32BB26HWFLLVJJNBNANCNFSM5VB2GIFA.
You are receiving this because you were mentioned.

<!-- gh-comment-id:1122365279 --> @SergeyNSW commented on GitHub (May 10, 2022): Thank you, looking forward to this improvement. > On 10 May 2022, at 16:03, Ken Hibino ***@***.***> wrote: > > > @SergeyNSW <https://github.com/SergeyNSW> thank you for this issue! > > It makes sense to me. We probably don't want to directly expose the cron.SchedulerParser since that would complicate the versioning, but since the SchedulerParser is defined with interfaces we can simply expose that same and pass it to cron package behind the scene. Let me work on this soon 👍 > > — > Reply to this email directly, view it on GitHub <https://github.com/hibiken/asynq/issues/447#issuecomment-1122361047>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AVODLEFCYNWO32BB26HWFLLVJJNBNANCNFSM5VB2GIFA>. > You are receiving this because you were mentioned. >
Author
Owner

@hibiken commented on GitHub (Jun 4, 2022):

Upon looking, it seems like spec like "@every 30s" works without a custom schedule parser. Does that work for you?

<!-- gh-comment-id:1146669259 --> @hibiken commented on GitHub (Jun 4, 2022): Upon looking, it seems like spec like `"@every 30s"` works without a custom schedule parser. Does that work for you?
Author
Owner

@SergeyNSW commented on GitHub (Jun 6, 2022):

yes, it works for me, thanks

<!-- gh-comment-id:1147562060 --> @SergeyNSW commented on GitHub (Jun 6, 2022): yes, it works for me, thanks
Author
Owner

@acaloiaro commented on GitHub (Apr 6, 2023):

Hi @hibiken -- I know this issue is closed, but I think it might be worth considering a different option, which some users might find less surprising:

In scheduler.go

- cron: cron.New(cron.WithLocation(loc)),
+ cron: cron.New(cron.WithLocation(loc), cron.WithSeconds()),

Which allows users to supply their cronspecs with the full six fields * * * * * *

<!-- gh-comment-id:1499368429 --> @acaloiaro commented on GitHub (Apr 6, 2023): Hi @hibiken -- I know this issue is closed, but I think it might be worth considering a different option, which some users might find less surprising: In `scheduler.go` ```go - cron: cron.New(cron.WithLocation(loc)), + cron: cron.New(cron.WithLocation(loc), cron.WithSeconds()), ``` Which allows users to supply their cronspecs with the full six fields `* * * * * *`
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/asynq#2231
No description provided.