Documentation
¶
Overview ¶
Package message defines the notification delivery log entity.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Count ¶
type Count struct {
Status Status `json:"status"`
Channel string `json:"channel"`
N int `json:"n"`
}
Count is the number of messages with one status on one channel.
type ListOptions ¶
ListOptions defines filtering options for listing messages.
type Message ¶
type Message struct {
ID id.MessageID `json:"id"`
AppID string `json:"app_id"`
EnvID string `json:"env_id,omitempty"`
TemplateID string `json:"template_id,omitempty"`
ProviderID string `json:"provider_id,omitempty"`
ProviderMessageID string `json:"provider_message_id,omitempty"`
Channel string `json:"channel"`
Recipient string `json:"recipient"`
Subject string `json:"subject,omitempty"`
Body string `json:"body,omitempty"`
Status Status `json:"status"`
Error string `json:"error,omitempty"`
Metadata map[string]string `json:"metadata,omitempty"`
Async bool `json:"async"`
Attempts int `json:"attempts"`
SentAt *time.Time `json:"sent_at,omitempty"`
DeliveredAt *time.Time `json:"delivered_at,omitempty"`
CreatedAt time.Time `json:"created_at"`
}
Message represents a sent or queued notification in the delivery log.
type Status ¶
type Status string
Status represents the delivery state of a message.
const ( StatusQueued Status = "queued" StatusSending Status = "sending" StatusSent Status = "sent" StatusFailed Status = "failed" StatusBounced Status = "bounced" StatusDelivered Status = "delivered" // StatusSuppressed is a send Herald chose not to make, because the // recipient opted out of this notification type on this channel. StatusSuppressed Status = "suppressed" // StatusFiltered is a device the caller's filter dropped. StatusFiltered Status = "filtered" )
Message status constants.
type Store ¶
type Store interface {
CreateMessage(ctx context.Context, m *Message) error
GetMessage(ctx context.Context, messageID id.MessageID) (*Message, error)
// RecordDelivery writes the outcome of a send: status, error, the vendor's
// message ID and when it was sent. Every field is written, so an empty
// value clears what was there.
RecordDelivery(ctx context.Context, messageID id.MessageID, d Delivery) error
ListMessages(ctx context.Context, appID string, opts ListOptions) ([]*Message, error)
// CountMessages groups the messages created at or after since by status
// and channel, sorted by status then channel.
CountMessages(ctx context.Context, appID string, since time.Time) ([]Count, error)
}
Store defines persistence operations for the message delivery log.
Click to show internal directories.
Click to hide internal directories.