Documentation ¶
Index ¶
Constants ¶
View Source
const AdminRouteCourier = "/courier"
View Source
const AdminRouteMessages = AdminRouteCourier + "/messages"
Variables ¶
View Source
var ErrQueueEmpty = errors.New("queue is empty")
Functions ¶
This section is empty.
Types ¶
type ConfigProvider ¶
type ConfigProvider interface {
CourierConfig() 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)) UseBackoff(b backoff.BackOff) }
func NewCourier ¶
func NewCourier(ctx context.Context, deps Dependencies) Courier
type Dependencies ¶
type Dependencies interface { PersistenceProvider x.LoggingProvider ConfigProvider x.HTTPClientProvider }
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 Handler ¶ added in v0.11.0
type Handler struct {
// contains filtered or unexported fields
}
func NewHandler ¶ added in v0.11.0
func NewHandler(r handlerDependencies) *Handler
func (*Handler) RegisterAdminRoutes ¶ added in v0.11.0
func (h *Handler) RegisterAdminRoutes(admin *x.RouterAdmin)
func (*Handler) RegisterPublicRoutes ¶ added in v0.11.0
func (h *Handler) RegisterPublicRoutes(public *x.RouterPublic)
type HandlerProvider ¶ added in v0.11.0
type HandlerProvider interface {
CourierHandler() *Handler
}
type Message ¶
type Message struct { ID uuid.UUID `json:"id" faker:"-" db:"id"` NID uuid.UUID `json:"-" faker:"-" db:"nid"` Status MessageStatus `json:"status" db:"status"` Type MessageType `json:"type" db:"type"` Recipient string `json:"recipient" db:"recipient"` Body string `json:"body" db:"body"` Subject string `json:"subject" db:"subject"` TemplateType TemplateType `json:"template_type" db:"template_type"` TemplateData []byte `json:"-" db:"template_data"` SendCount int `json:"send_count" db:"send_count"` // CreatedAt is a helper struct field for gobuffalo.pop. CreatedAt time.Time `json:"created_at" faker:"-" db:"created_at"` // UpdatedAt is a helper struct field for gobuffalo.pop. UpdatedAt time.Time `json:"updated_at" faker:"-" db:"updated_at"` }
swagger:model message
type MessageStatus ¶
type MessageStatus int
A Message's Status
swagger:model courierMessageStatus
const ( MessageStatusQueued MessageStatus = iota + 1 MessageStatusSent MessageStatusProcessing MessageStatusAbandoned )
func ToMessageStatus ¶ added in v0.11.0
func ToMessageStatus(str string) (MessageStatus, error)
func (MessageStatus) IsValid ¶ added in v0.11.0
func (ms MessageStatus) IsValid() error
func (MessageStatus) MarshalJSON ¶ added in v0.11.0
func (ms MessageStatus) MarshalJSON() ([]byte, error)
func (MessageStatus) String ¶ added in v0.11.0
func (ms MessageStatus) String() string
func (*MessageStatus) UnmarshalJSON ¶ added in v0.11.0
func (ms *MessageStatus) UnmarshalJSON(data []byte) error
type MessageType ¶
type MessageType int
A Message's Type
It can either be `email` or `phone`
swagger:model courierMessageType
const ( MessageTypeEmail MessageType = iota + 1 MessageTypePhone )
func ToMessageType ¶ added in v0.11.0
func ToMessageType(str string) (MessageType, error)
func (MessageType) IsValid ¶ added in v0.11.0
func (mt MessageType) IsValid() error
func (MessageType) MarshalJSON ¶ added in v0.11.0
func (mt MessageType) MarshalJSON() ([]byte, error)
func (MessageType) String ¶ added in v0.11.0
func (mt MessageType) String() string
func (*MessageType) UnmarshalJSON ¶ added in v0.11.0
func (mt *MessageType) UnmarshalJSON(data []byte) error
type MessagesFilter ¶
type MessagesFilter struct { x.PaginationParams // Status filters out messages based on status. // If no value is provided, it doesn't take effect on filter. // // required: false // in: query Status *MessageStatus `json:"status"` // Recipient filters out messages based on recipient. // If no value is provided, it doesn't take effect on filter. // // required: false // in: query Recipient string `json:"recipient"` }
nolint:deadcode,unused swagger:parameters adminListCourierMessages
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) IncrementMessageSendCount(context.Context, uuid.UUID) error // ListMessages lists all messages in the store given the page, itemsPerPage, status and recipient. // Returns list of messages, total count of messages satisfied by given filter, and error if any ListMessages(ctx context.Context, filter MessagesFilter) ([]Message, int64, error) }
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)
Source Files ¶
Click to show internal directories.
Click to hide internal directories.