queue

package
v0.0.4-beta Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2024 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Base

type Base struct {
	Context context.Context
	Cancel  context.CancelFunc
	// contains filtered or unexported fields
}

func NewBase

func NewBase() *Base

func (*Base) Add

func (q *Base) Add(queueName string, add QueueAdd) (string, error)

func (*Base) AddDelay

func (q *Base) AddDelay(queueName string, add QueueAddDelay) (string, error)

func (*Base) Close

func (q *Base) Close() error

func (*Base) Del

func (q *Base) Del(queueName string, id string) error

func (*Base) List

func (q *Base) List(queueName string, page int, limit int) ([]QueueItem, int64, error)

func (*Base) Names

func (q *Base) Names() []string

func (*Base) Register

func (q *Base) Register(queueName string, name string, callback func(ctx context.Context, params []byte) error) error

func (*Base) Start

func (q *Base) Start() error

func (*Base) Worker

func (q *Base) Worker(queueName string)

type BaseLogger

type BaseLogger struct{}

func (*BaseLogger) Info

func (l *BaseLogger) Info(msg string, args ...any)

type BaseQueue

type BaseQueue struct {
	QueueName string
	Queue     *goqite.Queue
	Job       *jobs.Runner
}

type Queue

type Queue interface {
	Worker(queueName string)
	Start() error
	Register(queueName, name string, callback func(ctx context.Context, params []byte) error) error
	Add(queueName string, add QueueAdd) (id string, err error)
	AddDelay(queueName string, add QueueAddDelay) (id string, err error)
	Del(queueName string, id string) error
	List(queueName string, page int, limit int) (data []QueueItem, count int64, err error)
	Names() []string
	Close() error
}

type QueueAdd

type QueueAdd struct {
	Name   string
	Params []byte
}

type QueueAddDelay

type QueueAddDelay struct {
	QueueAdd
	Delay time.Duration
}

type QueueItem

type QueueItem struct {
	ID        string         `json:"id"`
	QueueName string         `json:"queue_name"`
	Name      string         `json:"name"`
	Params    map[string]any `json:"params"`
	CreatedAt time.Time      `json:"created_at"`
	RunAt     time.Time      `json:"run_at"`
	Retried   int            `json:"retried"`
}

type Redis

type Redis struct {
	Context   context.Context
	Cancel    context.CancelFunc
	Server    *asynq.Server
	ServeMuxs map[string]*asynq.ServeMux
	Client    *asynq.Client
	Inspector *asynq.Inspector
}

func NewRedis

func NewRedis() *Redis

func (*Redis) Add

func (q *Redis) Add(queueName string, add QueueAdd) (string, error)

func (*Redis) AddDelay

func (q *Redis) AddDelay(queueName string, add QueueAddDelay) (string, error)

func (*Redis) Close

func (q *Redis) Close() error

func (*Redis) Del

func (q *Redis) Del(queueName string, id string) error

func (*Redis) List

func (q *Redis) List(queueName string, page int, limit int) ([]QueueItem, int64, error)

func (*Redis) Names

func (q *Redis) Names() []string

func (*Redis) Register

func (q *Redis) Register(queueName string, name string, callback func(ctx context.Context, params []byte) error) error

func (*Redis) Start

func (q *Redis) Start() error

func (*Redis) Worker

func (q *Redis) Worker(queueName string)

type TaskLogger

type TaskLogger struct {
	Logger *slog.Logger
}

func (*TaskLogger) Debug

func (t *TaskLogger) Debug(args ...interface{})

func (*TaskLogger) Error

func (t *TaskLogger) Error(args ...interface{})

func (*TaskLogger) Fatal

func (t *TaskLogger) Fatal(args ...interface{})

func (*TaskLogger) Info

func (t *TaskLogger) Info(args ...interface{})

func (*TaskLogger) Warn

func (t *TaskLogger) Warn(args ...interface{})

Jump to

Keyboard shortcuts

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