mirror of
https://github.com/oarkflow/mq.git
synced 2025-10-27 23:31:27 +08:00
update
This commit is contained in:
19
task.go
19
task.go
@@ -115,8 +115,9 @@ type Task struct {
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
ProcessedAt time.Time `json:"processed_at"`
|
||||
Expiry time.Time `json:"expiry"`
|
||||
Error error `json:"-"` // Don't serialize errors directly
|
||||
ErrorMsg string `json:"error,omitempty"` // Serialize error message if present
|
||||
DeferUntil time.Time `json:"defer_until,omitempty"` // NEW: For deferred task execution
|
||||
Error error `json:"-"` // Don't serialize errors directly
|
||||
ErrorMsg string `json:"error,omitempty"` // Serialize error message if present
|
||||
ID string `json:"id"`
|
||||
Topic string `json:"topic"`
|
||||
Status Status `json:"status"` // Use Status type instead of string
|
||||
@@ -232,6 +233,20 @@ func WithTTL(ttl time.Duration) TaskOption {
|
||||
}
|
||||
}
|
||||
|
||||
// TaskOption for deferring task execution until a specific time
|
||||
func WithDeferUntil(deferUntil time.Time) TaskOption {
|
||||
return func(t *Task) {
|
||||
t.DeferUntil = deferUntil
|
||||
}
|
||||
}
|
||||
|
||||
// TaskOption for deferring task execution for a specific duration
|
||||
func WithDeferDuration(duration time.Duration) TaskOption {
|
||||
return func(t *Task) {
|
||||
t.DeferUntil = time.Now().Add(duration)
|
||||
}
|
||||
}
|
||||
|
||||
// TaskOption for adding tags
|
||||
func WithTags(tags map[string]string) TaskOption {
|
||||
return func(t *Task) {
|
||||
|
||||
Reference in New Issue
Block a user