queue

package
v0.0.0-...-bf444b6 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2024 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultTaskTimeout   = 5 * time.Second // The default task timeout.
	DefaultTaskRetention = 5 * time.Minute // The default task retention.

	MessageQueueDefaultPriority = "default" // The default queue name.
	MessageQueueLowPriority     = "low"     // The low priority queue name.
	MessageQueueHighPriority    = "high"    // The high priority queue name.

	TaskTypeSystemHealthCheck   TaskType = iota + 1 // Health check task type.
	TaskTypeSystemLicenseExpiry                     // License expiry task type.
)

Variables

View Source
var (
	ErrNoSchedule  = errors.New("no schedule set")        // no schedule set
	ErrNoTask      = errors.New("no task set")            // no task set
	ErrReceiveTask = errors.New("failed to receive task") // failed to receive task
	ErrSendTask    = errors.New("failed to send task")    // failed to send task
)

Functions

func NewSystemHealthCheckTask

func NewSystemHealthCheckTask() (*asynq.Task, error)

NewSystemHealthCheckTask creates a new health check task.

func NewSystemLicenseExpiryTask

func NewSystemLicenseExpiryTask(l *license.License) (*asynq.Task, error)

NewSystemLicenseExpiryTask creates a new license expiry check task.

Types

type Client

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

Client is sending async task to the worker for processing.

func NewClient

func NewClient(opts ...ClientOption) (*Client, error)

NewClient creates a new client to send async tasks to Worker.

func (*Client) Close

func (c *Client) Close(ctx context.Context) error

Close closes the connection with the message broker.

func (*Client) Enqueue

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

Enqueue sends a task to the worker for processing.

func (*Client) GetTaskInfo

func (c *Client) GetTaskInfo(queue string, id string) (*asynq.TaskInfo, error)

GetTaskInfo returns the task info for the given task ID in a queue.

func (*Client) Ping

func (c *Client) Ping(ctx context.Context) error

Ping sends a sample task to the worker and waits for it to finish. If the task is not completed within 5 seconds, the task is canceled.

type ClientOption

type ClientOption func(*Client) error

ClientOption is a function that can be used to configure an async worker.

func WithClientConfig

func WithClientConfig(conf *config.WorkerConfig) ClientOption

WithClientConfig sets the config for the worker.

func WithClientLogger

func WithClientLogger(logger log.Logger) ClientOption

WithClientLogger sets the logger for the worker.

func WithClientTracer

func WithClientTracer(tracer tracing.Tracer) ClientOption

WithClientTracer sets the tracer for the worker.

type HealthCheckTaskPayload

type HealthCheckTaskPayload struct {
	Message string `json:"message"`
}

HealthCheckTaskPayload is the payload for the health check task.

type LicenseExpiryTaskPayload

type LicenseExpiryTaskPayload struct {
	LicenseID           string
	LicenseEmail        string
	LicenseOrganization string
	LicenseExpiresAt    time.Time
}

LicenseExpiryTaskPayload is the payload for the license expiry check task.

type Scheduler

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

Scheduler is a task scheduler that schedules tasks to be processed at a later time.

func NewScheduler

func NewScheduler(opts ...SchedulerOption) (*Scheduler, error)

NewScheduler returns a new task scheduler.

func (*Scheduler) Shutdown

func (s *Scheduler) Shutdown()

Shutdown shuts down the scheduler.

func (*Scheduler) Start

func (s *Scheduler) Start() error

Start starts the scheduler.

type SchedulerOption

type SchedulerOption func(*Scheduler) error

SchedulerOption is a function that can be used to configure an async scheduler.

func WithSchedulerConfig

func WithSchedulerConfig(conf *config.WorkerConfig) SchedulerOption

WithSchedulerConfig sets the config for the scheduler.

func WithSchedulerLogger

func WithSchedulerLogger(logger log.Logger) SchedulerOption

WithSchedulerLogger sets the logger for the scheduler.

func WithSchedulerTask

func WithSchedulerTask(schedule string, task *asynq.Task) SchedulerOption

WithSchedulerTask registers a task to be scheduled at a later time.

func WithSchedulerTracer

func WithSchedulerTracer(tracer tracing.Tracer) SchedulerOption

WithSchedulerTracer sets the tracer for the scheduler.

type TaskType

type TaskType uint8

TaskType is the type for system tasks.

func (TaskType) String

func (t TaskType) String() string

String returns the string representation of the system task type.

Jump to

Keyboard shortcuts

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