package worker
import "github.com/gobuffalo/buffalo/worker"
Index ¶
- type Args
- type Handler
- type Job
- type Simple
- func NewSimple() *Simple
- func NewSimpleWithContext(ctx context.Context) *Simple
- func (w *Simple) Perform(job Job) error
- func (w *Simple) PerformAt(job Job, t time.Time) error
- func (w *Simple) PerformIn(job Job, d time.Duration) error
- func (w *Simple) Register(name string, h Handler) error
- func (w *Simple) Start(ctx context.Context) error
- func (w *Simple) Stop() error
- type SimpleLogger
- type Worker
Types ¶
type Args ¶
type Args map[string]interface{}
Args are the arguments passed into a job
func (Args) String ¶
type Handler ¶
Handler function that will be run by the worker and given a slice of arguments
type Job ¶
type Job struct { // Queue the job should be placed into Queue string // Args that will be passed to the Handler when run Args Args // Handler that will be run by the worker Handler string }
Job to be processed by a Worker
func (Job) String ¶
type Simple ¶
type Simple struct { Logger SimpleLogger // contains filtered or unexported fields }
Simple is a basic implementation of the Worker interface that is backed using just the standard library and goroutines.
func NewSimple ¶
func NewSimple() *Simple
NewSimple creates a basic implementation of the Worker interface that is backed using just the standard library and goroutines.
func NewSimpleWithContext ¶
NewSimpleWithContext creates a basic implementation of the Worker interface that is backed using just the standard library and goroutines.
func (*Simple) Perform ¶
Perform a job as soon as possibly using a goroutine.
func (*Simple) PerformAt ¶
PerformAt performs a job at a particular time using a goroutine.
func (*Simple) PerformIn ¶
PerformIn performs a job after waiting for a specified amount using a goroutine.
func (*Simple) Register ¶
Register Handler with the worker
func (*Simple) Start ¶
Start the worker
func (*Simple) Stop ¶
Stop the worker
type SimpleLogger ¶
type SimpleLogger interface { Debugf(string, ...interface{}) Infof(string, ...interface{}) Errorf(string, ...interface{}) Debug(...interface{}) Info(...interface{}) Error(...interface{}) }
SimpleLogger is used by the Simple worker to write logs
type Worker ¶
type Worker interface { // Start the worker with the given context Start(context.Context) error // Stop the worker Stop() error // Perform a job as soon as possibly Perform(Job) error // PerformAt performs a job at a particular time PerformAt(Job, time.Time) error // PerformIn performs a job after waiting for a specified amount of time PerformIn(Job, time.Duration) error // Register a Handler Register(string, Handler) error }
Worker interface that needs to be implemented to be considered a "worker"
Source Files ¶
- Version
- v1.1.2 (latest)
- Published
- May 17, 2025
- Platform
- js/wasm
- Imports
- 7 packages
- Last checked
- 1 week ago –
Tools for package owners.