alerts

package
v0.0.0-...-fb6ebef Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2026 License: AGPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Alert

type Alert struct {
	ID          string     `json:"id"`
	Type        AlertType  `json:"type"`
	Title       string     `json:"title,omitempty"`
	Message     string     `json:"message"`
	Dismissible bool       `json:"dismissible"`
	Created     time.Time  `json:"created"`
	Expires     *time.Time `json:"expires,omitempty"`
}

Alert represents a single maintenance alert.

func (*Alert) IsActive

func (a *Alert) IsActive() bool

IsActive checks if the alert is currently active (not expired).

func (*Alert) IsExpired

func (a *Alert) IsExpired() bool

IsExpired checks if the alert has expired.

type AlertCollection

type AlertCollection struct {
	Alerts []Alert `json:"alerts"`
}

AlertCollection represents the complete alerts configuration.

type AlertType

type AlertType string

AlertType represents the type of alert to display.

const (
	AlertTypeInfo    AlertType = "info"
	AlertTypeWarning AlertType = "warning"
	AlertTypeError   AlertType = "error"
	AlertTypeSuccess AlertType = "success"
)

type Manager

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

Manager handles alert operations.

func NewManager

func NewManager() *Manager

NewManager creates a new alert manager.

func (*Manager) AddAlert

func (m *Manager) AddAlert(alert Alert) error

AddAlert adds a new alert to the collection.

func (*Manager) CleanupExpired

func (m *Manager) CleanupExpired() int

CleanupExpired removes all expired alerts.

func (*Manager) ClearAlerts

func (m *Manager) ClearAlerts()

ClearAlerts removes all alerts.

func (*Manager) GetActiveAlertCount

func (m *Manager) GetActiveAlertCount() int

GetActiveAlertCount returns the number of active alerts.

func (*Manager) GetAlert

func (m *Manager) GetAlert(id string) (*Alert, error)

GetAlert retrieves an alert by ID.

func (*Manager) GetAlertCount

func (m *Manager) GetAlertCount() int

GetAlertCount returns the total number of alerts.

func (*Manager) ListActiveAlerts

func (m *Manager) ListActiveAlerts() []Alert

ListActiveAlerts returns only active (non-expired) alerts.

func (*Manager) ListAlerts

func (m *Manager) ListAlerts() []Alert

ListAlerts returns all alerts.

func (*Manager) LoadFromJSON

func (m *Manager) LoadFromJSON(data []byte) error

LoadFromJSON loads alerts from JSON data.

func (*Manager) RemoveAlert

func (m *Manager) RemoveAlert(id string) error

RemoveAlert removes an alert by ID.

func (*Manager) ToJSON

func (m *Manager) ToJSON() ([]byte, error)

ToJSON serializes alerts to JSON.

func (*Manager) UpdateAlert

func (m *Manager) UpdateAlert(id string, updatedAlert Alert) error

UpdateAlert updates an existing alert.

Jump to

Keyboard shortcuts

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