feat: add support for tags in RetryableTask

This commit is contained in:
Derrick Hammer 2024-01-28 16:32:20 -05:00
parent 2a067102da
commit 4bb34315eb
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 7 additions and 1 deletions

View File

@ -40,6 +40,7 @@ type CronServiceImpl struct {
type RetryableTaskParams struct { type RetryableTaskParams struct {
Name string Name string
Tags []string
Function any Function any
Args []any Args []any
Attempt uint Attempt uint
@ -129,11 +130,16 @@ func (c *CronServiceImpl) RetryableTask(params RetryableTaskParams) CronJob {
}), gocron.AfterJobRuns(params.After)) }), gocron.AfterJobRuns(params.After))
name := gocron.WithName(params.Name) name := gocron.WithName(params.Name)
options := []gocron.JobOption{listeners, name}
if len(params.Tags) > 0 {
options = append(options, gocron.WithTags(params.Tags...))
}
return CronJob{ return CronJob{
Job: job, Job: job,
Task: task, Task: task,
Options: []gocron.JobOption{listeners, name}, Options: options,
} }
} }