courier

package
v0.6.0-alpha.1.pre.0 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2021 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrQueueEmpty = errors.New("queue is empty")

Functions

This section is empty.

Types

type Courier

type Courier struct {
	Dialer *gomail.Dialer
	// contains filtered or unexported fields
}

func NewSMTP

func NewSMTP(d smtpDependencies, c *config.Config) *Courier

func (*Courier) DispatchMessage

func (m *Courier) DispatchMessage(ctx context.Context, msg Message) error

func (*Courier) DispatchQueue

func (m *Courier) DispatchQueue(ctx context.Context) error

func (*Courier) QueueEmail

func (m *Courier) QueueEmail(ctx context.Context, t EmailTemplate) (uuid.UUID, error)

func (*Courier) Work

func (m *Courier) Work(ctx context.Context) error

type EmailTemplate

type EmailTemplate interface {
	json.Marshaler
	EmailSubject() (string, error)
	EmailBody() (string, error)
	EmailBodyPlaintext() (string, error)
	EmailRecipient() (string, error)
}

func NewEmailTemplateFromMessage

func NewEmailTemplateFromMessage(c *config.Config, m Message) (EmailTemplate, error)

type Message

type Message struct {
	ID           uuid.UUID     `json:"-" faker:"-" db:"id"`
	NID          uuid.UUID     `json:"-"  faker:"-" db:"nid"`
	Status       MessageStatus `json:"-" db:"status"`
	Type         MessageType   `json:"-" db:"type"`
	Recipient    string        `json:"-" db:"recipient"`
	Body         string        `json:"-" db:"body"`
	Subject      string        `json:"-" db:"subject"`
	TemplateType TemplateType  `json:"-" db:"template_type"`
	TemplateData []byte        `json:"-" db:"template_data"`

	// CreatedAt is a helper struct field for gobuffalo.pop.
	CreatedAt time.Time `json:"-" faker:"-" db:"created_at"`
	// UpdatedAt is a helper struct field for gobuffalo.pop.
	UpdatedAt time.Time `json:"-" faker:"-" db:"updated_at"`
}

func (*Message) GetID

func (m *Message) GetID() uuid.UUID

func (*Message) GetNID

func (m *Message) GetNID() uuid.UUID

func (Message) TableName

func (m Message) TableName(ctx context.Context) string

type MessageStatus

type MessageStatus int
const (
	MessageStatusQueued MessageStatus = iota + 1
	MessageStatusSent
	MessageStatusProcessing
)

type MessageType

type MessageType int
const (
	MessageTypeEmail MessageType = iota + 1
)

type PersistenceProvider

type PersistenceProvider interface {
	CourierPersister() Persister
}

type Persister

type Persister interface {
	AddMessage(context.Context, *Message) error

	NextMessages(context.Context, uint8) ([]Message, error)

	SetMessageStatus(context.Context, uuid.UUID, MessageStatus) error

	LatestQueuedMessage(ctx context.Context) (*Message, error)
}

type Provider

type Provider interface {
	Courier(ctx context.Context) *Courier
}

type TemplateType

type TemplateType string
const (
	TypeRecoveryInvalid     TemplateType = "recovery_invalid"
	TypeRecoveryValid       TemplateType = "recovery_valid"
	TypeVerificationInvalid TemplateType = "verification_invalid"
	TypeVerificationValid   TemplateType = "verification_valid"
	TypeTestStub            TemplateType = "stub"
)

func GetTemplateType

func GetTemplateType(t EmailTemplate) (TemplateType, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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