worker

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	QueueDefault  = "default"
	QueueCritical = "critical"
)
View Source
const EmailVerificationExpiration = time.Duration(time.Minute * 15)
View Source
const TaskSendAccountDeletedEmail = "task:send_account_deleted_email"
View Source
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

func (p *RedisTaskProcessor) ProcessSendVerifyEmail(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) Start

func (p *RedisTaskProcessor) Start() error

Registers tasks with the processor

type SendEmailPayload

type SendEmailPayload struct {
	Username string `json:"username"`
	Email    string `json:"email"`
}

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.

Jump to

Keyboard shortcuts

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