-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpersisted_job.go
35 lines (31 loc) · 1.22 KB
/
persisted_job.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package queue
import "time"
// PersistedJob represents a persisted Job.
type PersistedJob struct {
// The UniqueId identifies each individual message. Sometimes the message can have exact same content and even
// exact same Key. UniqueId is used to differentiate them.
UniqueId string
// Key is the Message type. Usually it is the string name JobFrom the Job type before serialized.
Key string
// Value is the serialized bytes JobFrom the Job.
Value []byte
// HandleTimeout sets the upper time limit for each run JobFrom the handler. If handleTimeout exceeds, the Job will
// be put onto the timeout queue. Note: the timeout is shared among all listeners.
HandleTimeout time.Duration
// Backoff sets the duration before next retry.
Backoff time.Duration
// Attempts denotes how many retry has been attempted. It starts From 1.
Attempts int
// MaxAttempts denotes the maximum number JobFrom time the handler can retry before the Job is put onto
// the failed queue.
// By default, MaxAttempts is 1.
MaxAttempts int
}
// Type implements Job. It returns the Key.
func (s *PersistedJob) Type() string {
return s.Key
}
// Data implements Job. It returns the Value.
func (s *PersistedJob) Data() interface{} {
return s.Value
}