Documentation
¶
Index ¶
Constants ¶
View Source
const ( // StatusPending means the message is waiting to be sent. StatusPending = Status("pending") // StatusSending means the message is in the process of being sent upstream StatusSending = Status("sending") // StatusQueuedRemotely means the message has been sent upstream, but is in a remote queue. StatusQueuedRemotely = Status("queued_remotely") // StatusSent means the message has been sent upstream, and has left the remote queue (if one exists). StatusSent = Status("sent") // StatusDelivered will be set on delivery if the upstream supports delivery confirmation. StatusDelivered = Status("delivered") // StatusFailed means the message failed to send. StatusFailed = Status("failed") // StatusStale is used if the message expired before being sent. StatusStale = Status("stale") )
Defined status values
Variables ¶
View Source
var ErrAbort = errors.New("aborted due to pause")
ErrAbort is returned when an early-abort is returned due to pause.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// MaxMessagesPerCycle determines the number of pending messages
// fetched per-cycle for delivery.
//
// Defaults to 50.
MaxMessagesPerCycle int
// RateLimit allows configuring rate limits per contact-method type.
RateLimit map[notification.DestType]*RateConfig
// Pausable is optional, and allows early-abort of
// message sending when IsPaused returns true.
Pausable lifecycle.Pausable
}
Config is used to configure the message sender.
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
DB implements a priority message sender using Postgres.
func (*DB) SendMessages ¶
SendMessages will send notifications using SendFunc.
func (*DB) UpdateMessageStatus ¶
func (db *DB) UpdateMessageStatus(ctx context.Context, status *notification.MessageStatus) error
UpdateMessageStatus will update the state of a message.
type Message ¶
type Message struct {
ID string
Type Type
Dest notification.Dest
AlertID int
AlertLogID int
VerifyID string
UserID string
ServiceID string
CreatedAt time.Time
SentAt time.Time
StatusAlertIDs []int
}
Message represents the data for an outgoing message.
type RateConfig ¶
type RateConfig struct {
// PerSecond determines the target messages-per-second limit.
PerSecond int
// Batch sets how often granularity of the rate limit.
Batch time.Duration
}
RateConfig allows setting egress rate limiting on messages.
type SendFunc ¶
type SendFunc func(context.Context, *Message) (*notification.MessageStatus, error)
SendFunc defines a function that sends messages.
type StatusFunc ¶
type StatusFunc func(ctx context.Context, id, providerMsgID string) (*notification.MessageStatus, error)
StatusFunc is used to fetch the latest status of a message.
type Type ¶
type Type string
Type represents the purpose of a message in the outgoing messages queue.
const ( TypeAlertNotification Type = "alert_notification" TypeTestNotification Type = "test_notification" TypeVerificationMessage Type = "verification_message" TypeAlertStatusUpdate Type = "alert_status_update" TypeAlertNotificationBundle Type = "alert_notification_bundle" TypeAlertStatusUpdateBundle Type = "alert_status_update_bundle" )
defined message types
Click to show internal directories.
Click to hide internal directories.