pushover

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2021 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultSendTimeout = time.Second * 3
	URL                = "https://api.pushover.net/1/messages.json"
	DefaultTemplate    = `{{ template "nm.default.text" . }}`
	MessageMaxLength   = 1024
)

Variables

This section is empty.

Functions

func NewPushoverNotifier

func NewPushoverNotifier(logger log.Logger, receivers []config.Receiver, notifierCfg *config.Config) notifier.Notifier

Types

type Notifier

type Notifier struct {
	// contains filtered or unexported fields
}

func (*Notifier) Notify

func (n *Notifier) Notify(ctx context.Context, data template.Data) []error

Notify sends messages to Pushover server. The preprocess logic of the pushover notification messages are as below: - The alert messages are filtered by AlertSelector first before sending to Pushover. - Pushover has a limit of 1024 characters on the message length (the exceeded part will be truncated), and each message may contain more than one Alert. Thus, a strategy of splitting the message is applied here, i.e., a message should contain as many Alerts as possible, and each message is sent one after another to ensure that they can be received in an intact manner by the user. - Render the message with a template, from which the Pushover message structure is constructed and its legitimacy is verified. - The Pushover message structure is encoded as a JSON string, a POST method is called to send a request to the Endpoint (https://api.pushover.net/1/messages.json), and an error will be raised if the status code of the returned response is not successful.

Jump to

Keyboard shortcuts

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