jobs

package
v0.0.0-...-cf0f558 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2024 License: GPL-3.0 Imports: 8 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Job

type Job struct {
	Queue       string  `json:"queue"`
	JobType     string  `json:"job_type" river:"unique"`
	JobArgs     JobArgs `json:"job_args" river:"unique"`
	JobDeadline int64   `json:"job_deadline"`
	Unique      bool    `json:"unique"`
}

Job defines a single job

func (*Job) HexKey

func (job *Job) HexKey() (string, error)

type JobArgs

type JobArgs map[string]any

type JobFn

type JobFn func() JobWorker

type JobLogger

type JobLogger struct {
	JobQueue
	// contains filtered or unexported fields
}

func NewJobLogger

func NewJobLogger(jq JobQueue) *JobLogger

func (*JobLogger) AddJob

func (w *JobLogger) AddJob(ctx context.Context, job Job) error

func (*JobLogger) AddJobType

func (w *JobLogger) AddJobType(jobFn JobFn) error

func (*JobLogger) AddJobs

func (w *JobLogger) AddJobs(ctx context.Context, jobs []Job) error

func (*JobLogger) AddQueue

func (w *JobLogger) AddQueue(queue string, workers int) error

func (*JobLogger) Run

func (w *JobLogger) Run(ctx context.Context) error

func (*JobLogger) RunJob

func (w *JobLogger) RunJob(ctx context.Context, job Job) error

func (*JobLogger) Stop

func (w *JobLogger) Stop(ctx context.Context) error

func (*JobLogger) Use

func (w *JobLogger) Use(jmw JobMiddleware)

type JobMapper

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

func NewJobMapper

func NewJobMapper() *JobMapper

func (*JobMapper) AddJobType

func (j *JobMapper) AddJobType(jobFn JobFn) error

func (*JobMapper) GetRunner

func (j *JobMapper) GetRunner(jobType string, jobArgs JobArgs) (JobWorker, error)

type JobMiddleware

type JobMiddleware func(JobWorker, Job) JobWorker

func NewJobRunLogger

func NewJobRunLogger(logger zerolog.Logger) JobMiddleware

type JobQueue

type JobQueue interface {
	Use(JobMiddleware)
	AddQueue(string, int) error
	AddJobType(JobFn) error
	AddJob(context.Context, Job) error
	AddJobs(context.Context, []Job) error
	RunJob(context.Context, Job) error
	Run(context.Context) error
	Stop(context.Context) error
}

Job queue

type JobRunLogger

type JobRunLogger struct {
	JobWorker
	// contains filtered or unexported fields
}

func (*JobRunLogger) Run

func (w *JobRunLogger) Run(ctx context.Context) error

type JobWorker

type JobWorker interface {
	Kind() string
	Run(context.Context) error
}

JobWorker defines a job worker

Jump to

Keyboard shortcuts

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