jobs

package
v1.57.3 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func OnFinish added in v1.55.0

func OnFinish(jobID int64, fn func()) (func(), error)

OnFinish adds listener to jobid that will be triggered when job is finished. It returns a function to cancel listening.

func SetInitialJobID

func SetInitialJobID(id int64)

SetInitialJobID allows for setting jobID before starting any jobs.

func SetOpt

func SetOpt(opt *rc.Options)

SetOpt sets the options when they are known

Types

type Job

type Job struct {
	ID        int64     `json:"id"`
	Group     string    `json:"group"`
	StartTime time.Time `json:"startTime"`
	EndTime   time.Time `json:"endTime"`
	Error     string    `json:"error"`
	Finished  bool      `json:"finished"`
	Success   bool      `json:"success"`
	Duration  float64   `json:"duration"`
	Output    rc.Params `json:"output"`
	Stop      func()    `json:"-"`
	// contains filtered or unexported fields
}

Job describes an asynchronous task started via the rc package

func NewJob added in v1.55.0

func NewJob(ctx context.Context, fn rc.Func, in rc.Params) (job *Job, out rc.Params, err error)

NewJob creates a Job and executes it on the global job queue, possibly in the background if _async is set

type Jobs

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

Jobs describes a collection of running tasks

func (*Jobs) Expire

func (jobs *Jobs) Expire()

Expire expires any jobs that haven't been collected

func (*Jobs) Get

func (jobs *Jobs) Get(ID int64) *Job

Get a job with a given ID or nil if it doesn't exist

func (*Jobs) IDs

func (jobs *Jobs) IDs() (IDs []int64)

IDs returns the IDs of the running jobs

func (*Jobs) NewJob added in v1.55.0

func (jobs *Jobs) NewJob(ctx context.Context, fn rc.Func, in rc.Params) (job *Job, out rc.Params, err error)

NewJob creates a Job and executes it, possibly in the background if _async is set

Jump to

Keyboard shortcuts

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