notify

package
v0.23.0 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReplaceReceivers

func ReplaceReceivers(dst, src kit.Receivers)

ReplaceReceivers swaps the contents of dst with src while keeping the same map instance.

func ReplaceRoutes

func ReplaceRoutes(dst, src ReceiverRoutes)

ReplaceRoutes swaps the contents of dst with src while keeping the same map instance.

Types

type Data

type Data struct {
	HeartbeatID string
	Title       string
	Status      string
	Subject     string
	Payload     string
	Timestamp   time.Time
	Interval    time.Duration
	LateAfter   time.Duration
	Receiver    string
	Vars        map[string]any
	CustomData  map[string]string
	Since       time.Duration
}

Data is the template context for heartbeat notifications.

func NewData

func NewData(event Event, receiver string, vars map[string]any, subject string) Data

NewData builds template data from a heartbeat event and notifykit receiver vars.

type Event

type Event struct {
	IDValue      string
	Heartbeat    string
	TitleValue   string
	StatusValue  string
	Body         string
	SinceValue   time.Duration
	Time         time.Time
	Interval     time.Duration
	LateAfter    time.Duration
	ReceiverList []kit.ReceiverID
}

Event wraps a heartbeat lifecycle event as a notifykit notification.

func NewEvent

func NewEvent(
	heartbeatID, title, status, body string,
	since time.Duration,
	timestamp time.Time,
	interval time.Duration,
	lateAfter time.Duration,
	receivers []kit.ReceiverID,
) *Event

NewEvent constructs an Event notification.

func (*Event) Data

func (e *Event) Data(receiver string, vars map[string]any, subject string) any

Data returns the receiver-scoped template data.

func (*Event) ID

func (e *Event) ID() string

ID returns the notification id used by notifykit.

func (*Event) ReceiverIDs

func (e *Event) ReceiverIDs() []kit.ReceiverID

ReceiverIDs returns explicit receiver routing.

type ReceiverRoutes

type ReceiverRoutes map[string][]kit.ReceiverID

ReceiverRoutes maps heartbeat IDs to explicit notifykit receiver IDs.

func ReceiversFromConfig

func ReceiversFromConfig(templateFS fs.FS, cfg *config.Config, logger *slog.Logger) (kit.Receivers, ReceiverRoutes, error)

ReceiversFromConfig builds notifykit receivers and heartbeat routes from config.

func (ReceiverRoutes) ReceiverIDs

func (r ReceiverRoutes) ReceiverIDs(heartbeatID string) []kit.ReceiverID

ReceiverIDs returns explicit receiver IDs for a heartbeat.

Jump to

Keyboard shortcuts

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