Documentation ¶
Index ¶
- Constants
- Variables
- type Alert
- type AlertBundle
- type AlertState
- type AlertStatus
- type DestID
- type Manager
- type Message
- type MessageLog
- type ProviderMessageID
- type Receiver
- type ReceiverSetter
- type Result
- type ResultReceiver
- type ScheduleOnCallUsers
- type SearchCursor
- type SearchOptions
- type SendResult
- type SentMessage
- type SignalMessage
- type State
- type Status
- type Store
- func (s *Store) Code(ctx context.Context, id string) (int, error)
- func (s *Store) FindManyMessageStatuses(ctx context.Context, strIDs []string) ([]SendResult, error)
- func (s *Store) LastMessageStatus(ctx context.Context, typ gadb.EnumOutgoingMessagesType, cmIDStr string, ...) (*SendResult, time.Time, error)
- func (s *Store) OriginalMessageStatus(ctx context.Context, alertID int, dstID DestID) (*SendResult, error)
- func (s *Store) Search(ctx context.Context, opts *SearchOptions) ([]MessageLog, error)
- func (s *Store) SendContactMethodTest(ctx context.Context, id string) error
- func (s *Store) SendContactMethodVerification(ctx context.Context, cmID string) error
- func (s *Store) TimeSeries(ctx context.Context, opts TimeSeriesOpts) ([]TimeSeriesBucket, error)
- func (s *Store) VerifyContactMethod(ctx context.Context, cmID string, code int) error
- type Test
- type TimeSeriesBucket
- type TimeSeriesOpts
- type UnknownSubjectError
- type User
- type Verification
Constants ¶
const ( StateSending = nfymsg.StateSending StateFailedPerm = nfymsg.StateFailedPerm StateFailedTemp = nfymsg.StateFailedTemp StateDelivered = nfymsg.StateDelivered StateSent = nfymsg.StateSent StateBundled = nfymsg.StateBundled StateUnknown = nfymsg.StateUnknown StatePending = nfymsg.StatePending AlertStateUnknown = nfymsg.AlertStateUnknown AlertStateUnacknowledged = nfymsg.AlertStateUnacknowledged AlertStateAcknowledged = nfymsg.AlertStateAcknowledged AlertStateClosed = nfymsg.AlertStateClosed )
const ( MessageTypeUnknown = "" MessageTypeAlert = gadb.EnumOutgoingMessagesTypeAlertNotification MessageTypeAlertStatus = gadb.EnumOutgoingMessagesTypeAlertStatusUpdate MessageTypeTest = gadb.EnumOutgoingMessagesTypeTestNotification MessageTypeVerification = gadb.EnumOutgoingMessagesTypeVerificationMessage MessageTypeAlertBundle = gadb.EnumOutgoingMessagesTypeAlertNotificationBundle // MessageTypeAlertStatusBundle is used for bundled status messages. // // Deprecated: Alert status messages are no longer bundled, status bundle // messages are now dropped. MessageTypeAlertStatusBundle = gadb.EnumOutgoingMessagesTypeAlertStatusUpdateBundle MessageTypeScheduleOnCallUsers = gadb.EnumOutgoingMessagesTypeScheduleOnCallNotification MessageTypeSignalMessage = gadb.EnumOutgoingMessagesTypeSignalMessage )
Allowed types
Variables ¶
var ErrStatusUnsupported = errors.New("status check unsupported by provider")
ErrStatusUnsupported should be returned when a Status() check is not supported by the provider.
Functions ¶
This section is empty.
Types ¶
type AlertBundle ¶ added in v0.24.0
type AlertBundle = nfymsg.AlertBundle
type AlertState ¶ added in v0.29.0
type AlertState = nfymsg.AlertState
type AlertStatus ¶
type AlertStatus = nfymsg.AlertStatus
type DestID ¶ added in v0.33.0
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager is used as an intermediary between Senders and Receivers. It should be constructed first (with NewManager()) and passed to Senders and Receivers that require it.
func NewManager ¶
NewManager initializes a new Manager.
func (*Manager) MessageStatus ¶ added in v0.28.0
func (mgr *Manager) MessageStatus(ctx context.Context, providerMsgID ProviderMessageID) (*Status, error)
MessageStatus will return the current status of a message.
func (*Manager) SendMessage ¶ added in v0.28.0
SendMessage tries all registered senders for the type given in Notification. An error is returned if there are no registered senders for the type or if an error is returned from all of them.
func (*Manager) SetResultReceiver ¶ added in v0.28.0
func (mgr *Manager) SetResultReceiver(ctx context.Context, recv ResultReceiver) error
SetResultReceiver will set the ResultReceiver as the target for all Receiver calls. It will panic if called multiple times.
type MessageLog ¶ added in v0.30.1
type MessageLog struct { ID string CreatedAt time.Time LastStatusAt time.Time MessageType gadb.EnumOutgoingMessagesType LastStatus State StatusDetails string SrcValue string AlertID int ProviderMsgID *ProviderMessageID UserID string UserName string ContactMethodID uuid.UUID ChannelID uuid.UUID ServiceID string ServiceName string SentAt *time.Time RetryCount int }
type ProviderMessageID ¶ added in v0.28.0
type ProviderMessageID = gadb.ProviderMessageID
type Receiver ¶
type Receiver interface { // SetMessageStatus can be used to update the state of a message. SetMessageStatus(ctx context.Context, externalID string, status *Status) error // Receive records a response to a previously sent message. Receive(ctx context.Context, callbackID string, result Result) error // ReceiveSubject records a response to a previously sent message from a provider/subject (e.g. Slack user). ReceiveSubject(ctx context.Context, providerID, subjectID, callbackID string, result Result) error // AuthLinkURL will generate a URL to link a provider and subject to a GoAlert user. AuthLinkURL(ctx context.Context, providerID, subjectID string, meta authlink.Metadata) (string, error) // Start indicates a user has opted-in for notifications to this contact method. Start(context.Context, gadb.DestV1) error // Stop indicates a user has opted-out of notifications from a contact method. Stop(context.Context, gadb.DestV1) error // IsKnownDest checks if the given destination is known/not disabled. IsKnownDest(ctx context.Context, dest gadb.DestV1) (bool, error) }
A Receiver processes incoming messages and responses.
type ReceiverSetter ¶ added in v0.27.0
type ReceiverSetter interface {
SetReceiver(Receiver)
}
ReceiverSetter is an optional interface a Sender can implement for use with two-way interactions.
type Result ¶
type Result int
Result specifies a response to a notification.
Possible notification responses.
type ResultReceiver ¶ added in v0.28.0
type ResultReceiver interface { SetSendResult(ctx context.Context, res *SendResult) error Receive(ctx context.Context, callbackID string, result Result) error ReceiveSubject(ctx context.Context, providerID, subjectID, callbackID string, result Result) error AuthLinkURL(ctx context.Context, providerID, subjectID string, meta authlink.Metadata) (string, error) Start(context.Context, gadb.DestV1) error Stop(context.Context, gadb.DestV1) error IsKnownDest(ctx context.Context, dest gadb.DestV1) (bool, error) }
A ResultReceiver processes notification responses.
type ScheduleOnCallUsers ¶ added in v0.28.0
type ScheduleOnCallUsers = nfymsg.ScheduleOnCallUsers
type SearchCursor ¶ added in v0.30.1
type SearchCursor struct { ID string `json:"i,omitempty"` CreatedAt time.Time `json:"n,omitempty"` }
SearchCursor is used to indicate a position in a paginated list.
type SearchOptions ¶ added in v0.30.1
type SearchOptions struct { Search string `json:"s,omitempty"` After SearchCursor `json:"a,omitempty"` CreatedAfter time.Time `json:"ca,omitempty"` CreatedBefore time.Time `json:"cb,omitempty"` // Omit specifies a list of message IDs to exclude from the results Omit []string `json:"o,omitempty"` Limit int `json:"-"` }
SearchOptions allow filtering and paginating the list of messages.
type SendResult ¶ added in v0.28.0
type SendResult = nfymsg.SendResult
type SentMessage ¶ added in v0.28.0
type SentMessage = nfymsg.SentMessage
type SignalMessage ¶ added in v0.33.0
type SignalMessage = nfymsg.SignalMessage
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
func (*Store) FindManyMessageStatuses ¶ added in v0.25.0
func (*Store) LastMessageStatus ¶ added in v0.26.0
func (s *Store) LastMessageStatus(ctx context.Context, typ gadb.EnumOutgoingMessagesType, cmIDStr string, from time.Time) (*SendResult, time.Time, error)
LastMessageStatus will return the MessageStatus and creation time of the most recent message of the requested type for the provided contact method ID, if one was created from the provided from time.
func (*Store) OriginalMessageStatus ¶ added in v0.28.0
func (s *Store) OriginalMessageStatus(ctx context.Context, alertID int, dstID DestID) (*SendResult, error)
OriginalMessageStatus will return the status of the first alert notification sent to `dest` for the given `alertID`.
func (*Store) Search ¶ added in v0.30.1
func (s *Store) Search(ctx context.Context, opts *SearchOptions) ([]MessageLog, error)
func (*Store) SendContactMethodTest ¶
func (*Store) SendContactMethodVerification ¶
func (*Store) TimeSeries ¶ added in v0.31.0
func (s *Store) TimeSeries(ctx context.Context, opts TimeSeriesOpts) ([]TimeSeriesBucket, error)
TimeSeries returns a list of time series buckets for the given search options.
type TimeSeriesBucket ¶ added in v0.31.0
type TimeSeriesOpts ¶ added in v0.31.0
type TimeSeriesOpts struct { SearchOptions TimeSeriesOrigin time.Time TimeSeriesInterval time.Duration }
type UnknownSubjectError ¶ added in v0.30.0
type UnknownSubjectError struct {
AlertID int
}
UnknownSubjectError is returned from ReceiveSubject when the subject is unknown.
func (UnknownSubjectError) Error ¶ added in v0.30.0
func (e UnknownSubjectError) Error() string
type Verification ¶
type Verification = nfymsg.Verification