Help us shape the future of Go! Take the 2026 Go Developer Survey

notifications

package
v0.305.3 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2026 License: Apache-2.0 Imports: 3 Imported by: 3

Documentation

Index

Constants

View Source
const (
	ConfigurationUnsuccessful = "Configuration reload has failed."
	StartingUp                = "Prometheus is starting and replaying the write-ahead log (WAL)."
	ShuttingDown              = "Prometheus is shutting down and gracefully stopping all operations."
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Notification

type Notification struct {
	Text   string    `json:"text"`
	Date   time.Time `json:"date"`
	Active bool      `json:"active"`
}

Notification represents an individual notification message.

type Notifications

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

Notifications stores a list of Notification objects. It also manages live subscribers that receive notifications via channels.

func NewNotifications

func NewNotifications(maxSubscribers int, reg prometheus.Registerer) *Notifications

NewNotifications creates a new Notifications instance.

func (*Notifications) AddNotification

func (n *Notifications) AddNotification(text string)

AddNotification adds a new notification or updates the timestamp if it already exists.

func (*Notifications) DeleteNotification

func (n *Notifications) DeleteNotification(text string)

DeleteNotification removes the first notification that matches the provided text. The deleted notification is sent to subscribers with Active: false before being removed.

func (*Notifications) Get

func (n *Notifications) Get() []Notification

Get returns a copy of the list of notifications for safe access outside the struct.

func (*Notifications) Sub

func (n *Notifications) Sub() (<-chan Notification, func(), bool)

Sub allows a client to subscribe to live notifications. It returns a channel where the subscriber will receive notifications and a function to unsubscribe. Each subscriber has its own goroutine to handle notifications and prevent blocking.

Jump to

Keyboard shortcuts

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