emailworker

package
v1.19.1 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2026 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrTaskNotActive = errors.New("batch email task is no longer active")

Functions

This section is empty.

Types

type DailyLimitReached added in v1.18.0

type DailyLimitReached struct {
	NextAt time.Time
}

DailyLimitReached asks the queue shell to persist a continuation for the next civil day instead of keeping one queue worker asleep for hours.

func (*DailyLimitReached) Error added in v1.18.0

func (e *DailyLimitReached) Error() string

type ErrorInfo

type ErrorInfo struct {
	Error string `json:"error"`
	Email string `json:"email"`
	Time  int64  `json:"time"`
}

type MessageLogStore added in v1.19.0

type MessageLogStore interface {
	Insert(ctx context.Context, data *logEntity.SystemLog) error
	Update(ctx context.Context, data *logEntity.SystemLog) error
}

type TaskStore

type TaskStore interface {
	FindOneByType(ctx context.Context, id int64, typ task.Type) (*task.Task, error)
	UpdateActive(ctx context.Context, data *task.Task) (bool, error)
	UpdateActiveProgress(ctx context.Context, data *task.Task) (bool, error)
	UpdateActiveProgressWithError(ctx context.Context, data *task.Task, taskError *task.TaskError) (bool, error)
	InsertError(ctx context.Context, data *task.TaskError) error
	FindErrors(ctx context.Context, taskIDs []int64) ([]*task.TaskError, error)
}

TaskStore is the minimal task repository interface needed by the batch-email worker.

type Worker

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

func NewWorker

func NewWorker(ctx context.Context, id int64, tasks TaskStore, sender emailpkg.Sender, options ...WorkerOption) *Worker

func (*Worker) GetID

func (w *Worker) GetID() int64

func (*Worker) Start

func (w *Worker) Start() error

Start processes a batch-email task until completion or cancellation.

type WorkerManager

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

WorkerManager owns asynchronous batch-email workers. It is an application worker, so it belongs in internal rather than the reusable email package.

var (
	Manager *WorkerManager
)

func NewWorkerManager

func NewWorkerManager() *WorkerManager

func (*WorkerManager) GetWorker

func (m *WorkerManager) GetWorker(id int64) *Worker

GetWorker returns the worker currently assigned to id.

func (*WorkerManager) RemoveWorker

func (m *WorkerManager) RemoveWorker(id int64)

RemoveWorker cancels and removes the worker assigned to id.

func (*WorkerManager) RunWorker added in v1.18.0

func (m *WorkerManager) RunWorker(ctx context.Context, id int64, tasks TaskStore, sender emailpkg.Sender, options ...WorkerOption) error

RunWorker keeps queue acknowledgement coupled to the actual campaign run. A duplicate delivery in the same process is harmless: the existing worker remains authoritative for that database task.

type WorkerOption added in v1.19.0

type WorkerOption func(*Worker)

func WithMessageLogs added in v1.19.0

func WithMessageLogs(logs MessageLogStore, platform string) WorkerOption

Jump to

Keyboard shortcuts

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