jobs

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2018 License: MIT Imports: 11 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrImmediateReschedule = errors.New("commit tx, and reschedule ASAP")
	ErrDoNotReschedule     = errors.New("no need to reschedule, we are done")
)

Functions

func MustPGXConfigFromCloudFoundry

func MustPGXConfigFromCloudFoundry() *pgx.ConnConfig

Return a database object, using the CloudFoundry environment data

func PGXConfigFromCloudFoundry

func PGXConfigFromCloudFoundry() (*pgx.ConnConfig, error)

Return a database object, using the CloudFoundry environment data

Types

type Handler

type Handler struct {
	PGXConnConfig *pgx.ConnConfig
	InitSQL       string
	WorkerCount   int
	WorkerMap     map[string]*JobConfig
	OnStart       func(qc *que.Client, pgxPool *pgx.ConnPool, logger *log.Logger) error
	Logger        *log.Logger
	QueueName     string
}

func (*Handler) WorkForever

func (h *Handler) WorkForever() error

type JobConfig

type JobConfig struct {
	F JobFunc

	// Debug logging
	VerboseLogging bool

	// One will only be called at once
	Singleton bool

	// Will be rescheduled upon success
	Duration time.Duration
	// contains filtered or unexported fields
}

func (*JobConfig) CloneWith

func (scw *JobConfig) CloneWith(qc *que.Client, logger *log.Logger) *JobConfig

func (*JobConfig) Run

func (scw *JobConfig) Run(job *que.Job) error

type JobFunc

type JobFunc func(qc *que.Client, logger *log.Logger, job *que.Job, tx *pgx.Tx) error

JobFunc should do a thing. Return either: nil => wrapper will schedule the next cron (if a cron), then commit the tx. ErrImmediateReschedule => wrapper will commit the tx, then try it again immediately. ErrDidNotReschedule => wrapper will rollback the tx, and if a cron, will not reschedule or retry. any other error => wrapper rollback the tx, and allow que to reschedule

Jump to

Keyboard shortcuts

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