Documentation
¶
Overview ¶
Package worker provides support for distributing and processing tasks.
Index ¶
- Constants
- type Config
- type Logger
- func (logger *Logger) Debug(args ...interface{})
- func (logger *Logger) Error(args ...interface{})
- func (logger *Logger) Fatal(args ...interface{})
- func (logger *Logger) Info(args ...interface{})
- func (logger *Logger) Print(level zerolog.Level, args ...interface{})
- func (logger *Logger) Printf(ctx context.Context, format string, v ...interface{})
- func (logger *Logger) Warn(args ...interface{})
- type PayloadSendNotification
- type PayloadSendVerifyEmail
- type RedisTaskDistributor
- func (distributor *RedisTaskDistributor) DistributeTaskSendNotification(ctx context.Context, payload *PayloadSendNotification, opts ...asynq.Option) error
- func (distributor *RedisTaskDistributor) DistributeTaskSendVerifyEmail(ctx context.Context, payload *PayloadSendVerifyEmail, opts ...asynq.Option) error
- type RedisTaskProcessor
- func (processor *RedisTaskProcessor) ProcessTaskSendNotification(ctx context.Context, task *asynq.Task) error
- func (processor *RedisTaskProcessor) ProcessTaskSendVerifyEmail(ctx context.Context, task *asynq.Task) error
- func (processor *RedisTaskProcessor) Shutdown()
- func (processor *RedisTaskProcessor) Start() error
- type TaskDistributor
- type TaskProcessor
- type Worker
Constants ¶
View Source
const ( QueueCritical = "critical" QueueDefault = "default" )
View Source
const TaskSendNotification = "task:send_notification"
View Source
const TaskSendVerifyEmail = "task:send_verify_email"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { Log *zerolog.Logger DB *sqlx.DB RedisOpt asynq.RedisClientOpt Mailer mailer.Mailer }
Config represents the configuration needed to create a Worker instance.
type PayloadSendNotification ¶
type PayloadSendVerifyEmail ¶
type PayloadSendVerifyEmail struct {
Email string `json:"email"`
}
type RedisTaskDistributor ¶
type RedisTaskDistributor struct {
// contains filtered or unexported fields
}
RedisTaskDistributor distributes tasks using Redis.
func (*RedisTaskDistributor) DistributeTaskSendNotification ¶
func (distributor *RedisTaskDistributor) DistributeTaskSendNotification(ctx context.Context, payload *PayloadSendNotification, opts ...asynq.Option) error
func (*RedisTaskDistributor) DistributeTaskSendVerifyEmail ¶
func (distributor *RedisTaskDistributor) DistributeTaskSendVerifyEmail(ctx context.Context, payload *PayloadSendVerifyEmail, opts ...asynq.Option) error
DistributeTaskSendVerifyEmail enqueues a task to send a verification email.
type RedisTaskProcessor ¶
type RedisTaskProcessor struct {
// contains filtered or unexported fields
}
RedisTaskProcessor processes tasks using Redis.
func (*RedisTaskProcessor) ProcessTaskSendNotification ¶
func (*RedisTaskProcessor) ProcessTaskSendVerifyEmail ¶
func (processor *RedisTaskProcessor) ProcessTaskSendVerifyEmail(ctx context.Context, task *asynq.Task) error
ProcessTaskSendVerifyEmail processes the task to send a verification email.
func (*RedisTaskProcessor) Shutdown ¶
func (processor *RedisTaskProcessor) Shutdown()
func (*RedisTaskProcessor) Start ¶
func (processor *RedisTaskProcessor) Start() error
type TaskDistributor ¶
type TaskDistributor interface { DistributeTaskSendVerifyEmail( ctx context.Context, payload *PayloadSendVerifyEmail, opts ...asynq.Option, ) error DistributeTaskSendNotification( ctx context.Context, payload *PayloadSendNotification, opts ...asynq.Option, ) error }
TaskDistributor defines the interface for task distribution.
type TaskProcessor ¶
type TaskProcessor interface { Start() error Shutdown() ProcessTaskSendVerifyEmail(ctx context.Context, task *asynq.Task) error ProcessTaskSendNotification(ctx context.Context, task *asynq.Task) error }
TaskProcessor defines the interface for task processing.
type Worker ¶
type Worker struct { TaskDistributor TaskProcessor }
Worker contains configuration for task distribution and processing.
Click to show internal directories.
Click to hide internal directories.