workers

package
v0.0.0-...-6aee27a Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EmailStatus

type EmailStatus = string

EmailStatus reflects the possible statuses for emails in any state

const (
	// EmailCreated reflects emails where the email has been acknowledged, but not yet sent
	EmailCreated EmailStatus = "created"
	// EmailSent reflects emails that have been attempted to be delivered (and probably succeeded)
	EmailSent EmailStatus = "sent"
	// EmailErrored reflects emails that could not be sent for any reason
	EmailErrored EmailStatus = "error"
)

type EmailWorker

type EmailWorker struct {
	SleepAfterWorkDuration   time.Duration
	SleepAfterNoWorkDuration time.Duration
	OnPassComplete           func()
	// contains filtered or unexported fields
}

EmailWorker is a struct that creates the functionality of reading emails from the email queue (db table) and passing those to the email servicer

func MakeEmailWorker

func MakeEmailWorker(db *database.Connection, servicer emailservices.EmailServicer, logger logging.Logger) EmailWorker

MakeEmailWorker constructs an EmailWorker

func (*EmailWorker) GetEmailQueue

func (w *EmailWorker) GetEmailQueue() *chan emailservices.EmailJob

GetEmailQueue returns the channel that the EmailWorker uses to add emails to the outgoing queue. The email servicer should read from this channel to know what emails to send out.

func (*EmailWorker) IsRunning

func (w *EmailWorker) IsRunning() bool

IsRunning returns the current state of the worker. If running, the worker is processing new emails returns true if the worker is running, false otherwise.

func (*EmailWorker) Start

func (w *EmailWorker) Start()

Start starts the email worker's processing. Note that calling this while the worker is already running will do nothing

func (*EmailWorker) Stop

func (w *EmailWorker) Stop()

Stop stops the email worker at it's next opporunity (generally between individual email sends) any email that has been picked up by the servicer will run to completion.

Jump to

Keyboard shortcuts

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