You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
asynq.TaskID doesn't work for periodic tasks as it can only be passed when setting up the scheduler
To Reproduce
setting up a scheduler using the following, does not generate a separate taskId per periodic task enqueued
scheduler.Register(
interval,
asynq.NewTask(task, nil),
asynq.Queue(queue),
asynq.TaskID(primitive.NewObjectID().Hex()), // mongodb object id as task id
)
Expected behavior
ability to set taskId for periodic tasks, there are multiple solutions
change the signature of preEnqueueFunc to return *asynq.Task (most flexible, allows to customize all different attributes)
add a scheduler option such as TaskOpts which can be a func with the following signature func() []asynq.Option {} where it gets executed for every task
bonus: have a validation check on options passed to scheduler.Register and fail if option is not supported
Environment (please complete the following information):
OS: N/A
Version of asynq package v0.24.0
Additional context
currently this solution works but but definitely is an anti pattern
scheduler:=asynq.NewScheduler(opts, &asynq.SchedulerOpts{
PreEnqueueFunc: func(task*asynq.Task, opts []asynq.Option) {
iftask!=nil {
*task=*asynq.NewTask(
task.Type(),
task.Payload(),
asynq.TaskID(primitive.NewObjectID().Hex()), // mongodb object id as task id
)
}
},
PostEnqueueFunc: func(task*asynq.TaskInfo, errerror) {
logger.Debugf("enqueued task %s", task.ID) // logs the correct task idiferr!=nil {
logger.Errorf("error while enqueuing task %s", err)
}
},
})
The text was updated successfully, but these errors were encountered:
Describe the bug
asynq.TaskID doesn't work for periodic tasks as it can only be passed when setting up the scheduler
To Reproduce
setting up a scheduler using the following, does not generate a separate taskId per periodic task enqueued
Expected behavior
ability to set taskId for periodic tasks, there are multiple solutions
bonus: have a validation check on options passed to scheduler.Register and fail if option is not supported
Environment (please complete the following information):
asynq
package v0.24.0Additional context
currently this solution works but but definitely is an anti pattern
The text was updated successfully, but these errors were encountered: