worker

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TypeEmailSend = "email:send"

	QueueTransactional = "transactional"
	QueueBulk          = "bulk"
	QueueLow           = "low"
)

Variables

This section is empty.

Functions

func NewEmailSendTask

func NewEmailSendTask(emailID uint, opts ...asynq.Option) (*asynq.Task, error)

NewEmailSendTask creates an Asynq task to send an email.

Types

type EmailSendHandler

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

EmailSendHandler processes email:send tasks from the Asynq queue.

func (*EmailSendHandler) OnFailed

func (h *EmailSendHandler) OnFailed(fn func())

OnFailed sets a callback invoked after each permanently failed email send.

func (*EmailSendHandler) OnSent

func (h *EmailSendHandler) OnSent(fn func())

OnSent sets a callback invoked after each successful email send.

func (*EmailSendHandler) ProcessTask

func (h *EmailSendHandler) ProcessTask(_ context.Context, t *asynq.Task) error

ProcessTask handles an email:send task.

type EmailSendPayload

type EmailSendPayload struct {
	EmailID uint `json:"email_id"`
}

type ExhaustedErrorHandler

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

ExhaustedErrorHandler marks emails as permanently failed when Asynq exhausts all retries. It implements asynq.ErrorHandler.

func NewExhaustedErrorHandler

func NewExhaustedErrorHandler(emailRepo *repositories.EmailRepository, dispatcher *webhook.Dispatcher, onFailed func()) *ExhaustedErrorHandler

func (*ExhaustedErrorHandler) HandleError

func (e *ExhaustedErrorHandler) HandleError(_ context.Context, t *asynq.Task, err error)

type Producer

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

Producer enqueues email tasks into Redis via Asynq.

func NewProducer

func NewProducer(redisAddr, redisPassword string, maxRetries int) *Producer

func (*Producer) Close

func (p *Producer) Close() error

Close closes the underlying Asynq client.

func (*Producer) EnqueueEmailSend

func (p *Producer) EnqueueEmailSend(emailID uint, queue string) error

EnqueueEmailSend enqueues an email for background delivery.

func (*Producer) EnqueueEmailSendAt

func (p *Producer) EnqueueEmailSendAt(emailID uint, queue string, sendAt time.Time) error

EnqueueEmailSendAt enqueues an email for delivery at the specified time.

Jump to

Keyboard shortcuts

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