Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrTaskNotActive = errors.New("batch email task is no longer active")
Functions ¶
This section is empty.
Types ¶
type DailyLimitReached ¶ added in v1.18.0
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 MessageLogStore ¶ added in v1.19.0
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 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