job

package
v0.1.0-beta Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 14, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Body

type Body string

type Delay

type Delay time.Duration

type Id

type Id string

type Job

type Job struct {
	Topic   Topic       `json:"topic"`
	ID      Id          `json:"id"`
	Delay   Delay       `json:"delay"`
	TTR     TTR         `json:"ttr"`
	Body    Body        `json:"body"`
	Version Version     `json:"version"`
	Mutex   lock.Locker `json:"-"`
}

func Get

func Get(topic Topic, id Id, lockerFunc lock.LockerFunc) (*Job, error)

Get a job entity before load all information from storage

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

func (j *Job) GetDelayTimeFromNow() time.Time

GetDelayTimeFromNow return how much time to wait for delaying

func (*Job) GetName

func (j *Job) GetName() string

GetName return job unique name getter

func (*Job) GetNameWithVersion

func (j *Job) GetNameWithVersion() NameVersion

func (*Job) GetTTRTimeFromNow

func (j *Job) GetTTRTimeFromNow() time.Time

GetTTRTimeFromNow return how much time to wait until overtime

func (*Job) IsValid

func (j *Job) IsValid() error

IsValid check job is valid. job is not nil and topic and id is not empty

func (*Job) IsVersionSame

func (j *Job) IsVersionSame(v Version) bool

IsVersionSame return whether j's version is equal to v

func (*Job) Lock

func (j *Job) Lock() error

Lock lock the job

func (*Job) Unlock

func (j *Job) Unlock() (bool, error)

Unlock unlock the job

type NameVersion

type NameVersion string

func NewNameVersion

func NewNameVersion(topic Topic, id Id, version Version) NameVersion

func NewNameVersionString

func NewNameVersionString(str string) NameVersion

func (NameVersion) MarshalBinary

func (nv NameVersion) MarshalBinary() ([]byte, error)

func (NameVersion) Parse

func (nv NameVersion) Parse() (Topic, Id, Version, error)

type TTR

type TTR time.Duration

type Topic

type Topic string

type Version

type Version struct {
	// contains filtered or unexported fields
}

func LoadVersion

func LoadVersion(vs string) (Version, error)

func NewVersion

func NewVersion() Version

func (Version) Equal

func (v Version) Equal(v2 Version) bool

func (Version) MarshalJSON

func (v Version) MarshalJSON() ([]byte, error)

func (Version) String

func (v Version) String() string

func (*Version) UnmarshalJSON

func (v *Version) UnmarshalJSON(b []byte) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL