alerts

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2023 License: MIT Imports: 6 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 is a unique identifier for the alert.
	ID types.Hash256 `json:"id"`
	// Severity is the severity of the alert.
	Severity Severity `json:"severity"`
	// Message is a human-readable message describing the alert.
	Message string `json:"message"`
	// Data is a map of arbitrary data that can be used to provide
	// additional context to the alert.
	Data      map[string]any `json:"data,omitempty"`
	Timestamp time.Time      `json:"timestamp"`
}

An Alert is a dismissible message that is displayed to the user.

type Manager

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

A Manager manages the host's alerts.

func NewManager

func NewManager() *Manager

NewManager initializes a new alerts manager.

func (*Manager) Active

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

Active returns the host's active alerts.

func (*Manager) Dismiss

func (m *Manager) Dismiss(ids ...types.Hash256)

Dismiss removes the alerts with the given IDs.

func (*Manager) Register

func (m *Manager) Register(a Alert)

Register registers a new alert with the manager

type Severity

type Severity uint8

Severity indicates the severity of an alert.

const (
	// SeverityInfo indicates that the alert is informational.
	SeverityInfo Severity = iota + 1
	// SeverityWarning indicates that the alert is a warning.
	SeverityWarning
	// SeverityError indicates that the alert is an error.
	SeverityError
	// SeverityCritical indicates that the alert is critical.
	SeverityCritical
)

func (Severity) MarshalJSON

func (s Severity) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface.

func (Severity) String

func (s Severity) String() string

String implements the fmt.Stringer interface.

func (*Severity) UnmarshalJSON

func (s *Severity) UnmarshalJSON(b []byte) error

UnmarshalJSON implements the json.Unmarshaler interface.

Jump to

Keyboard shortcuts

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