alerts

package
v1.0.8 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2024 License: MIT Imports: 12 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IDForAccount added in v1.0.7

func IDForAccount(alertID [32]byte, id rhpv3.Account) types.Hash256

func IDForContract added in v1.0.7

func IDForContract(alertID [32]byte, fcid types.FileContractID) types.Hash256

func IDForHost added in v1.0.7

func IDForHost(alertID [32]byte, hk types.PublicKey) types.Hash256

func IDForSlab added in v1.0.7

func IDForSlab(alertID [32]byte, slabKey object.EncryptionKey) types.Hash256

func RandomAlertID added in v1.0.7

func RandomAlertID() types.Hash256

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 Alerter

type Alerter interface {
	Alerts(_ context.Context, opts AlertsOpts) (resp AlertsResponse, err error)
	RegisterAlert(_ context.Context, a Alert) error
	DismissAlerts(_ context.Context, ids ...types.Hash256) error
}

func WithOrigin

func WithOrigin(alerter Alerter, origin string) Alerter

WithOrigin wraps an Alerter in an originAlerter which always attaches the origin field to alerts.

type AlertsOpts added in v1.0.6

type AlertsOpts struct {
	Offset   int
	Limit    int
	Severity Severity
}

type AlertsResponse added in v1.0.6

type AlertsResponse struct {
	Alerts  []Alert `json:"alerts"`
	HasMore bool    `json:"hasMore"`
	Totals  struct {
		Info     int `json:"info"`
		Warning  int `json:"warning"`
		Error    int `json:"error"`
		Critical int `json:"critical"`
	} `json:"totals"`
}

func (AlertsResponse) Total added in v1.0.6

func (ar AlertsResponse) Total() int

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) Alerts added in v1.0.6

func (m *Manager) Alerts(_ context.Context, opts AlertsOpts) (AlertsResponse, error)

Alerts returns the host's active alerts.

func (*Manager) DismissAlerts

func (m *Manager) DismissAlerts(ctx context.Context, ids ...types.Hash256) error

DismissAlerts implements the Alerter interface.

func (*Manager) RegisterAlert

func (m *Manager) RegisterAlert(ctx context.Context, alert Alert) error

RegisterAlert implements the Alerter interface.

func (*Manager) RegisterWebhookBroadcaster

func (m *Manager) RegisterWebhookBroadcaster(b webhooks.Broadcaster)

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) LoadString added in v1.0.6

func (s *Severity) LoadString(str string) error

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