mirror of
https://github.com/hibiken/asynq.git
synced 2026-04-26 07:25:56 +03:00
[GH-ISSUE #890] Scheduler: How to get the schedule time of the task in the task handler? #2465
Labels
No labels
CLI
bug
designing
documentation
duplicate
enhancement
good first issue
good first issue
help wanted
idea
invalid
investigate
needs-more-info
performance
pr-welcome
pull-request
question
wontfix
work in progress
work in progress
work-around-available
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/asynq#2465
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @asravankumar on GitHub (Jun 2, 2024).
Original GitHub issue: https://github.com/hibiken/asynq/issues/890
Originally assigned to: @hibiken on GitHub.
I have a requirement, where i require the scheduled time of a task in the handler.
For example, I have a task A which is scheduled to invoke every day, then in the task handler I need the scheduled time to tag the task invocation to that day.
For the same, I did the following. I passed the scheduledAt as part of the payload. While registering the task in the scheduler, I gave the time.Now().UTC() to get the current time.
You can see above while registering, I created the task with current time.
What i see is for the all the invocations of this task, the scheduledAt value is constant and is basically the time at which that code has been executed.
I think my approach might be wrong..
Please help me in two things,
@RiskyFeryansyahP commented on GitHub (Jun 4, 2024):
Hi @asravankumar, you can use Periodic Task Dynamic with the
GetConfigsimplementation that will be fetched at every interval (configurable). For the payload, you can use amap,DB, or something else to keep the data dynamic. Every time a task is executed, you need to update the data in themap,DB, or other storage solution.