queue

package
v1.16.5 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2025 License: MIT Imports: 3 Imported by: 19

Documentation

Index

Constants

View Source
const (
	DriverSync      string = "sync"
	DriverDatabase  string = "database"
	DriverMachinery string = "machinery"
	DriverCustom    string = "custom"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Arg

type Arg struct {
	Value any    `json:"value"`
	Type  string `json:"type"`
}

type Args

type Args struct {
	// Specify connection
	Connection string
	// Specify queue
	Queue string
	// Concurrent num
	Concurrent int
	// Tries maximum attempts
	Tries int
}

type ChainJob added in v1.15.12

type ChainJob struct {
	Delay time.Time `json:"delay"`
	Job   Job       `json:"job"`
	Args  []Arg     `json:"args"`
}

type Config added in v1.15.12

type Config interface {
	config.Config
	Debug() bool
	DefaultConnection() string
	DefaultQueue() string
	DefaultConcurrent() int
	Driver(connection string) string
	FailedDatabase() string
	FailedTable() string
	Via(connection string) any
}

type Driver added in v1.15.12

type Driver interface {
	// Driver returns the driver name for the driver.
	Driver() string
	// Pop pops the next job off of the queue.
	Pop(queue string) (ReservedJob, error)
	// Push pushes the job onto the queue.
	Push(task Task, queue string) error
}

type DriverCreator added in v1.15.12

type DriverCreator interface {
	Create(connection string) (Driver, error)
}

type FailedJob added in v1.15.12

type FailedJob interface {
	Connection() string
	Queue() string
	FailedAt() *carbon.DateTime
	Retry() error
	Signature() string
	UUID() string
}

type Failer added in v1.15.12

type Failer interface {
	All() ([]FailedJob, error)
	Get(connection, queue string, uuids []string) ([]FailedJob, error)
}

type Job

type Job interface {
	// Signature set the unique signature of the job.
	Signature() string
	// Handle executes the job.
	Handle(args ...any) error
}

type JobStorer added in v1.15.12

type JobStorer interface {
	All() []Job
	Call(signature string, args []any) error
	Get(signature string) (Job, error)
	Register(jobs []Job)
}

type JobWithShouldRetry added in v1.15.12

type JobWithShouldRetry interface {
	// ShouldRetry determines if the job should be retried based on the error.
	ShouldRetry(err error, attempt int) (retryable bool, delay time.Duration)
}

type Jobs deprecated

type Jobs = ChainJob

Deprecated: Use ChainJob instead.

type PendingJob added in v1.15.12

type PendingJob interface {
	// Delay dispatches the task after the given delay.
	Delay(time time.Time) PendingJob
	// Dispatch dispatches the task.
	Dispatch() error
	// DispatchSync dispatches the task synchronously.
	DispatchSync() error
	// OnConnection sets the connection of the task.
	OnConnection(connection string) PendingJob
	// OnQueue sets the queue of the task.
	OnQueue(queue string) PendingJob
}

type Queue

type Queue interface {
	// Connection gets a driver instance by connection name
	Connection(name string) (Driver, error)
	// Chain creates a chain of jobs to be processed one by one, passing
	Chain(jobs []ChainJob) PendingJob
	// Failer gets failed jobs
	Failer() Failer
	// GetJob gets job by signature
	GetJob(signature string) (Job, error)
	// GetJobs gets all jobs
	GetJobs() []Job
	// JobStorer gets job storer
	JobStorer() JobStorer
	// Job add a job to queue
	Job(job Job, args ...[]Arg) PendingJob
	// Register register jobs
	Register(jobs []Job)
	// Worker create a queue worker
	Worker(payloads ...Args) Worker
}

type ReservedJob added in v1.15.12

type ReservedJob interface {
	Delete() error
	Task() Task
}

type Task

type Task struct {
	ChainJob
	UUID  string     `json:"uuid"`
	Chain []ChainJob `json:"chain"`
}

type Worker

type Worker interface {
	Run() error
	Shutdown() error
}

Jump to

Keyboard shortcuts

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