emailworker

package
v1.15.16 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2026 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ErrorInfo

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

type TaskStore

type TaskStore interface {
	FindOne(ctx context.Context, id int64) (*task.Task, error)
	Update(ctx context.Context, data *task.Task) 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) *Worker

func (*Worker) GetID

func (w *Worker) GetID() int64

func (*Worker) IsRunning

func (w *Worker) IsRunning() uint8

func (*Worker) Start

func (w *Worker) Start()

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(tasks TaskStore, sender emailpkg.Sender) *WorkerManager

func (*WorkerManager) AddWorker

func (m *WorkerManager) AddWorker(id int64)

AddWorker starts a worker only when one is not already processing the task.

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.

Jump to

Keyboard shortcuts

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