jobs

package
v0.0.0-...-c07ec26 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// StatusCompleted is the status of a job that has been completed
	StatusCompleted = "completed"
	// StatusScheduled is the status of a job that has been scheduled
	StatusScheduled = "scheduled"
	// StatusFailed is the status of a job that has failed
	StatusFailed = "failed"
	// StatusCanceled is the status of a job that has been canceled
	StatusCanceled = "canceled"
	// StatusInitialized is the status of a job that is currently being processed
	StatusInitialized = "initialized"
)

Variables

View Source
var (
	// // ErrNoJobsAvailable is returned when no jobs are available
	// ErrNoJobsAvailable = errors.New("no jobs available")
	// ErrJobNotFound is returned when no job is found
	ErrJobNotFound = errors.New("job not found")
)

Functions

This section is empty.

Types

type Job

type Job struct {
	ID          string          `json:"id"`
	Queue       string          `json:"queue"`
	Status      string          `json:"status"`
	Arguments   json.RawMessage `json:"arguments"`
	Result      json.RawMessage `json:"result"`
	LastError   string          `json:"last_error"`
	RetryCount  int             `json:"retry_count"`
	Options     Options         `json:"options"`
	ScheduledAt time.Time       `json:"scheduled_at,omitempty"`
	StartedAt   time.Time       `json:"started_at"`
	CreatedAt   time.Time       `json:"created_at"`
	UpdatedAt   time.Time       `json:"updated_at"`
}

Job could use generics for params and result

func (Job) ParseArguments

func (j Job) ParseArguments(dest interface{}) error

func (Job) ScheduleRetry

func (j Job) ScheduleRetry(t time.Time) Job

func (Job) SetArguments

func (j Job) SetArguments(args interface{}) (Job, error)

SetArguments sets the arguments of the job

func (Job) SetLastError

func (j Job) SetLastError(err error) Job

SetLastError sets the last error of the job

func (Job) SetResult

func (j Job) SetResult(res interface{}) (Job, error)

SetResult sets the result of the job

func (Job) SetStatus

func (j Job) SetStatus(status string) Job

SetStatus sets the status of the job

func (Job) ShouldRetry

func (j Job) ShouldRetry() bool

type Options

type Options struct {
	MaxRetries    int           `json:"max_retries"`
	RetryInterval time.Duration `json:"retry_interval"`
}

func (*Options) Scan

func (o *Options) Scan(src interface{}) error

func (Options) Value

func (o Options) Value() (driver.Value, error)

Jump to

Keyboard shortcuts

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