Documentation
¶
Index ¶
Constants ¶
const ( QueueDefault = "default" QueueCritical = "critical" )
const EmailVerificationExpiration = time.Duration(time.Minute * 15)
const TaskSendAccountDeletedEmail = "task:send_account_deleted_email"
const TaskSendVerifyEmail = "task:send_verify_email"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type RedisTaskDistributor ¶
type RedisTaskDistributor struct {
// contains filtered or unexported fields
}
Implements the TaskDistributor interface
func (*RedisTaskDistributor) DistributeSendEmail ¶
func (d *RedisTaskDistributor) DistributeSendEmail(ctx context.Context, payload *SendEmailPayload, emailTask string) error
DistributeSendEmail implements the TaskDistributor interface and distributes email sending tasks.
type RedisTaskProcessor ¶
type RedisTaskProcessor struct {
// contains filtered or unexported fields
}
Implements the TaskProcessor interface
func (*RedisTaskProcessor) ProcessSendAccountDeletedEmail ¶
func (p *RedisTaskProcessor) ProcessSendAccountDeletedEmail(ctx context.Context, task *asynq.Task) error
ProcessSendVerifyEmail implements the TaskProcessor interface and processes the task task:send_verify_email from the background worker
func (*RedisTaskProcessor) ProcessSendVerifyEmail ¶
ProcessSendVerifyEmail implements the TaskProcessor interface and processes the task task:send_verify_email from the background worker
func (*RedisTaskProcessor) Start ¶
func (p *RedisTaskProcessor) Start() error
Registers tasks with the processor
type SendEmailPayload ¶
SendVerifyEmailPayload will contain all data that we want to store in the Redis queue.
type TaskDistributor ¶
type TaskDistributor interface {
DistributeSendEmail(ctx context.Context, payload *SendEmailPayload, emailTask string) error
}
Generic interface for a task distributor.
func NewRedisTaskDistributor ¶
func NewRedisTaskDistributor(redisOpts asynq.RedisClientOpt) TaskDistributor
Returns a new RedisTaskDistributor
type TaskProcessor ¶
type TaskProcessor interface {
Start() error
ProcessSendVerifyEmail(ctx context.Context, task *asynq.Task) error
ProcessSendAccountDeletedEmail(ctx context.Context, task *asynq.Task) error
}
Generic interface so it's easier to mock for unit testing
func NewRedisTaskProcessor ¶
func NewRedisTaskProcessor(redisOpts asynq.RedisClientOpt, store db.Store, mailer util.EmailSender) TaskProcessor
Creates a new Redis task processor.