worker

package
v0.2.20 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TypeQueued    queueType = iota
	TypeScheduled queueType = iota
	TypePeriodic  queueType = iota
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Args

type Args map[string]interface{}

type Dispatcher

type Dispatcher struct {
	WorkerPool chan chan Job
	MaxWorkers int
	// contains filtered or unexported fields
}

func NewDispatcher

func NewDispatcher(namespace, redisURL string, maxWorkers int) *Dispatcher

func (Dispatcher) AddHandler

func (d Dispatcher) AddHandler(queue string, fn func(Args) error)

func (Dispatcher) CancelBatch

func (d Dispatcher) CancelBatch(queue string, batchID string, cancelledBy string) (int64, error)

func (Dispatcher) CancelTask

func (d Dispatcher) CancelTask(queue string, index int64, cancelledBy string) (int64, error)

func (Dispatcher) Close

func (d Dispatcher) Close() error

func (Dispatcher) EnqueueJob

func (d Dispatcher) EnqueueJob(job *Job) error

EnqueueJob ads a job to the queue and will be run as soon as possible

func (Dispatcher) GetTaskLists

func (d Dispatcher) GetTaskLists() ([]string, error)

func (Dispatcher) ListJobs

func (d Dispatcher) ListJobs(queueName string) ([]*Job, error)

func (Dispatcher) RemoveQueue

func (d Dispatcher) RemoveQueue(queue string, queueType queueType) (err error)

func (Dispatcher) RemoveSwn

func (d Dispatcher) RemoveSwn(userID int64, slug string, lastOnly bool) error

func (Dispatcher) Run

func (d Dispatcher) Run()

type Job

type Job struct {
	Queue       string     `json:"queue"`
	Args        Args       `json:"args"`
	BatchID     string     `json:"batch_id"`
	Error       string     `json:"error,omitempt"`
	CreatedAt   *time.Time `json:"created_at,omitempty"`
	RunAt       *time.Time `json:"run_at,omitempty"`
	Cron        string     `json:"cron,omitempty"`
	LastRun     *time.Time `json:"last_run,omitempty"`
	Retry       int64      `json:"retry"`
	Type        queueType  `json:"type"`
	CancelledAt *time.Time `json:"cancelled_at,omitempty"`
	ProcessedAt *time.Time `json:"processed_at,omitempty"`
	CreatedBy   string     `json:"created_by,omitempty"`
	CancelledBy string     `json:"cancelled_by,omitempty"`
}

func NewScheduledJob

func NewScheduledJob(queue string, when string, args Args) *Job

type Meta

type Meta map[string]interface{}

type Worker

type Worker struct {
	WorkerPool chan chan Job
	JobChannel chan Job
	// contains filtered or unexported fields
}

func NewWorker

func NewWorker(namespace string, conn redis.Conn, workerPool chan chan Job) Worker

func (Worker) Start

func (w Worker) Start(queueTasks *map[string]func(Args) error)

func (Worker) Stop

func (w Worker) Stop()

Jump to

Keyboard shortcuts

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