notifier

package
v1.15.1 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package notifier implements push notifications.

Index

Constants

View Source
const (
	// ShoutrrrDefaultTimeout is the default timeout for a UptimeKuma ping.
	ShoutrrrDefaultTimeout = 10 * time.Second
)

Variables

This section is empty.

Functions

func DescribeShoutrrrService added in v1.14.1

func DescribeShoutrrrService(ppfmt pp.PP, proto string) string

DescribeShoutrrrService gives a human-readable description for a service.

Types

type Composed added in v1.14.2

type Composed []Notifier

Composed represents the composite of multiple notifiers.

func NewComposed added in v1.14.2

func NewComposed(nots ...Notifier) Composed

NewComposed creates a new composed notifier.

func (Composed) Describe added in v1.14.2

func (ns Composed) Describe(yield func(name string, params string) bool)

Describe calls [Notifier.Describe] for each notifier in the group with the callback.

func (Composed) Send added in v1.14.2

func (ns Composed) Send(ctx context.Context, ppfmt pp.PP, msg Message) bool

Send calls [Notifier.Send] for each notifier in the group.

type Message added in v1.14.1

type Message []string

Message holds the messages and success/failure status for notifiers.

func MergeMessages added in v1.14.1

func MergeMessages(msgs ...Message) Message

MergeMessages keeps only the ones with highest severity.

func NewMessage added in v1.14.1

func NewMessage() Message

NewMessage creates a new empty Message.

func NewMessagef added in v1.14.1

func NewMessagef(format string, args ...any) Message

NewMessagef creates a new MonitorMessage containing one formatted string.

func (Message) Format added in v1.14.1

func (m Message) Format() string

Format turns the message into a single string.

func (Message) IsEmpty added in v1.14.1

func (m Message) IsEmpty() bool

IsEmpty checks if the message is empty.

type Notifier

type Notifier interface {
	// Describe a notifier in a human-readable format by calling callback with service names and params.
	Describe(yield func(name, params string) bool)

	// Send out a message.
	Send(ctx context.Context, ppfmt pp.PP, msg Message) bool
}

Notifier is an abstract service for push notifications.

type Shoutrrr

type Shoutrrr struct {
	// The router
	Router *router.ServiceRouter

	// The services
	ServiceDescriptions []string
}

Shoutrrr wraps a handler of a shoutrrr router.

func NewShoutrrr

func NewShoutrrr(ppfmt pp.PP, rawURLs []string) (Shoutrrr, bool)

NewShoutrrr creates a new shoutrrr notifier.

func (Shoutrrr) Describe

func (s Shoutrrr) Describe(yield func(string, string) bool)

Describe calls callback on each registered notification service.

func (Shoutrrr) Send

func (s Shoutrrr) Send(_ context.Context, ppfmt pp.PP, msg Message) bool

Send sents the message msg.

Jump to

Keyboard shortcuts

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