async

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrLoadingDatabaseHost = errors.New("error loading task queue host")
	ErrMTLSRedisClientOpt  = errors.New("error redis client opt")
	ErrSecretTypeQueue     = errors.New("unsupported secret type for task queue")
	ErrACLNotEnabled       = errors.New("ACL is not enabled for task queue")
	ErrACLPassword         = errors.New("ACL is not load password for redis client")
	ErrACLUsername         = errors.New("ACL is not load username for redis client")
)
View Source
var (
	ErrEnqueueingTask    = errors.New("enqueue task")
	ErrClientShutdown    = errors.New("client shutdown")
	ErrStartingWorker    = errors.New("starting worker")
	ErrCreatingScheduler = errors.New("creating scheduler")
	ErrRunningScheduler  = errors.New("running scheduler")
	ErrReadingConfig     = errors.New("error reading scheduler task config file")
	ErrInvalidConfig     = errors.New("invalid scheduler task config")
)

Functions

This section is empty.

Types

type App

type App struct {
	// contains filtered or unexported fields
}

func New

func New(cfg *conf.Config) (*App, error)

New creates a new instance of App

func (*App) Client

func (a *App) Client() *asynq.Client

func (*App) Enqueue

func (a *App) Enqueue(
	ctx context.Context,
	task *asynq.Task,
	opts ...asynq.Option,
) (*asynq.TaskInfo, error)

Enqueue is used to run tasks

func (*App) Inspector

func (a *App) Inspector() *asynq.Inspector

func (*App) RegisterTasks

func (a *App) RegisterTasks(ctx context.Context, handlers []TaskHandler)

RegisterTasks registers multiple task handlers

func (*App) RunScheduler

func (a *App) RunScheduler() error

RunScheduler starts the cron job scheduling It starts the cron related tasks defined in the schedulerTasksConfig

func (*App) RunWorker

func (a *App) RunWorker(ctx context.Context) error

RunWorker starts the worker process to process the tasks

func (*App) Shutdown

func (a *App) Shutdown(ctx context.Context) error

Shutdown gracefully shuts down the worker and scheduler

type Client

type Client interface {
	Close() error
	Enqueue(task *asynq.Task, opts ...asynq.Option) (*asynq.TaskInfo, error)
	EnqueueContext(ctx context.Context, task *asynq.Task, opts ...asynq.Option) (*asynq.TaskInfo, error)
	Ping() error
}

type MockClient

type MockClient struct {
	CallCount int
	LastTask  *asynq.Task
	Error     error
}

MockClient implements the AsyncClient interface for testing

func (*MockClient) Close

func (m *MockClient) Close() error

func (*MockClient) Enqueue

func (m *MockClient) Enqueue(task *asynq.Task, opt ...asynq.Option) (*asynq.TaskInfo, error)

func (*MockClient) EnqueueContext

func (m *MockClient) EnqueueContext(_ context.Context, task *asynq.Task, opt ...asynq.Option) (*asynq.TaskInfo, error)

func (*MockClient) Ping

func (m *MockClient) Ping() error

type ScheduledTaskConfigProvider

type ScheduledTaskConfigProvider struct {
	Config *config.Config
}

ScheduledTaskConfigProvider implements asynq PeriodicTaskConfigProvider interface.

func (*ScheduledTaskConfigProvider) GetConfigs

GetConfigs Parses the yaml file and return a list of PeriodicTaskConfigs.

type TaskHandler

type TaskHandler interface {
	ProcessTask(ctx context.Context, task *asynq.Task) error
	TaskType() string
}

TaskHandler defines the interface for handling async

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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