courier

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

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

Go to latest
Published: Mar 21, 2022 License: Apache-2.0 Imports: 19 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 ConfigProvider

type ConfigProvider interface {
	CourierConfig(ctx context.Context) config.CourierConfigs
}

type Courier

type Courier interface {
	Work(ctx context.Context) error
	QueueEmail(ctx context.Context, t EmailTemplate) (uuid.UUID, error)
	QueueSMS(ctx context.Context, t SMSTemplate) (uuid.UUID, error)
	SmtpDialer() *gomail.Dialer
	DispatchQueue(ctx context.Context) error
	DispatchMessage(ctx context.Context, msg Message) error
	SetGetEmailTemplateType(f func(t EmailTemplate) (TemplateType, error))
	SetNewEmailTemplateFromMessage(f func(d template.Dependencies, msg Message) (EmailTemplate, error))
}

func NewCourier

func NewCourier(ctx context.Context, deps Dependencies) Courier

type EmailTemplate

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

func NewEmailTemplateFromMessage

func NewEmailTemplateFromMessage(d template.Dependencies, msg 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"`
}

swagger:ignore

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
	MessageStatusAbandoned
)

type MessageType

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

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 SMSTemplate

type SMSTemplate interface {
	json.Marshaler
	SMSBody(context.Context) (string, error)
	PhoneNumber() (string, error)
}

func NewSMSTemplateFromMessage

func NewSMSTemplateFromMessage(d Dependencies, m Message) (SMSTemplate, error)

type TemplateType

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

func GetEmailTemplateType

func GetEmailTemplateType(t EmailTemplate) (TemplateType, error)

func SMSTemplateType

func SMSTemplateType(t SMSTemplate) (TemplateType, error)

Directories

Path Synopsis
sms

Jump to

Keyboard shortcuts

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