Documentation ¶
Index ¶
- type Body
- type Delay
- type Empty
- type ID
- type Job
- func (j *Job) GetDelayTimeFromNow() time.Time
- func (j *Job) GetName() string
- func (j *Job) GetNameWithVersion() NameVersion
- func (j *Job) GetTTRTimeFromNow() time.Time
- func (j *Job) IsValid() error
- func (j *Job) IsVersionSame(v Version) bool
- func (j *Job) Lock() error
- func (j *Job) SetVersion(ts int64)
- func (j *Job) Unlock() (bool, error)
- type NameVersion
- type TTR
- type Topic
- type Version
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Job ¶
type Job struct { Topic Topic `json:"topic,omitempty"` ID ID `json:"id,omitempty"` Delay Delay `json:"delay,omitempty"` TTR TTR `json:"ttr,omitempty"` Body Body `json:"body,omitempty"` Version Version `json:"version,omitempty"` Mutex lock.Locker `json:"-"` }
Job job for delay queue
func New ¶
func New(topic Topic, id ID, delay Delay, ttr TTR, body Body, lockerFunc lock.LockerFunc) (*Job, error)
New return a job with everything init
func (*Job) GetDelayTimeFromNow ¶
GetDelayTimeFromNow return how much time to wait for delaying
func (*Job) GetNameWithVersion ¶
func (j *Job) GetNameWithVersion() NameVersion
GetNameWithVersion return name version of job
func (*Job) GetTTRTimeFromNow ¶
GetTTRTimeFromNow return how much time to wait until overtime
func (*Job) IsVersionSame ¶
IsVersionSame return whether j's version is equal to v
type NameVersion ¶
type NameVersion string
NameVersion name version, combination of topic, id and version
func NewNameVersion ¶
func NewNameVersion(topic Topic, id ID, version Version) NameVersion
NewNameVersion create new name version object
func NewNameVersionString ¶
func NewNameVersionString(str string) NameVersion
NewNameVersionString convert string to name version
func (NameVersion) MarshalBinary ¶
func (nv NameVersion) MarshalBinary() ([]byte, error)
MarshalBinary for json encode
type Version ¶
type Version struct {
// contains filtered or unexported fields
}
Version job version, it is a time object. nano timestamp
func LoadVersion ¶
LoadVersion load version from a string
func (Version) MarshalJSON ¶
MarshalJSON json marshall
func (*Version) UnmarshalJSON ¶
UnmarshalJSON json unmarshall