jobs

package
v1.67.3 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package jobs manages background jobs that the rc is running.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetJobID added in v1.62.1

func GetJobID(ctx context.Context) (jobID int64, ok bool)

GetJobID gets the Job from the context if possible

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 GetJob added in v1.62.1

func GetJob(ctx context.Context) (job *Job, ok bool)

GetJob gets the Job from the context if possible

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

func (*Job) OnFinish added in v1.62.1

func (job *Job) OnFinish(fn func()) func()

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

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