Documentation ¶
Index ¶
Constants ¶
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.