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

notification

package
v0.1.0-rc.6 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2026 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Overview

Package notification owns persisted notification destinations.

Index

Constants

This section is empty.

Variables

View Source
var ErrInUse = errors.New("notification channel is assigned to an alert rule")

ErrInUse means a rule still references this destination.

View Source
var ErrInvalidChannel = errors.New("invalid notification channel")

ErrInvalidChannel means the name, channel type or configuration is unsupported.

View Source
var ErrNotFound = errors.New("notification channel not found")

ErrNotFound means the requested notification channel does not exist.

View Source
var ErrSilenceNotFound = errors.New("notification silence not found")

ErrSilenceNotFound means the silence is absent from this owner's native collection.

Functions

This section is empty.

Types

type Channel

type Channel struct {
	ID       string
	Name     string
	Type     string
	Config   json.RawMessage
	Delivery *DeliverySettings
}

Channel describes a named destination with type-specific configuration. Saving a channel does not enable delivery.

type DeliverySettings

type DeliverySettings struct {
	GroupBy               string `json:"group_by"`
	GroupWaitSeconds      int    `json:"group_wait_seconds"`
	GroupIntervalSeconds  int    `json:"group_interval_seconds"`
	RepeatIntervalSeconds int    `json:"repeat_interval_seconds"`
}

DeliverySettings controls native notification grouping and timing for one channel. Durations are whole seconds; Alertmanager owns the corresponding timers.

type Publisher

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

Publisher reconciles stored channels with the owned Alertmanager configuration. The application owns its lifetime and calls Sync serially.

func NewPublisher

func NewPublisher(store *Store, baseURL, dataDirectory string) (*Publisher, error)

NewPublisher binds publication to one managed engine's HTTP origin.

func (*Publisher) Sync

func (publisher *Publisher) Sync(ctx context.Context) error

Sync writes generated changes, reloads, then verifies the native state. An unchanged file is not proof of successful loading: failed reloads retry.

type Silence

type Silence struct {
	ID               string    `json:"id"`
	MonitorID        string    `json:"monitor_id,omitempty"`
	AgentInstanceUID string    `json:"agent_instance_uid,omitempty"`
	StartsAt         time.Time `json:"starts_at"`
	EndsAt           time.Time `json:"ends_at"`
	CreatedBy        string    `json:"created_by"`
	Comment          string    `json:"comment"`
	State            string    `json:"state"`
}

Silence is an Agent- or Monitor-scoped view of a native Alertmanager silence. State and timestamps are read from the engine, not evaluated by Arveld.

type SilenceClient

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

SilenceClient sends notification suspensions to the owned Alertmanager. Alertmanager owns their identity, storage and expiration.

func NewSilenceClient

func NewSilenceClient(baseURL string) (*SilenceClient, error)

NewSilenceClient binds silence operations to one managed engine's HTTP origin.

func (*SilenceClient) CancelAgentSilence

func (client *SilenceClient) CancelAgentSilence(ctx context.Context, agentUID, id string) error

CancelAgentSilence expires a silence only after verifying its whole-Agent scope. Alertmanager treats repeated expiration as success while the entry is retained.

func (*SilenceClient) CancelMonitorSilence

func (client *SilenceClient) CancelMonitorSilence(ctx context.Context, monitorID, id string) error

CancelMonitorSilence expires a silence only after verifying its Monitor scope. Alertmanager treats repeated expiration as success while the entry is retained.

func (*SilenceClient) CreateAgentSilence

func (client *SilenceClient) CreateAgentSilence(ctx context.Context, agentUID string, startsAt, endsAt time.Time, comment string) (string, error)

CreateAgentSilence silences an Agent and its Monitors for a validated time window. agentUID must use the canonical UUID representation carried by native alerts.

func (*SilenceClient) CreateMonitorSilence

func (client *SilenceClient) CreateMonitorSilence(ctx context.Context, monitorID string, startsAt, endsAt time.Time, comment string) (string, error)

CreateMonitorSilence creates an exact Monitor silence for a validated time window. A failed request is not retried: the engine may already have accepted the write.

func (*SilenceClient) ListAgentSilences

func (client *SilenceClient) ListAgentSilences(ctx context.Context, agentUID string) ([]Silence, error)

ListAgentSilences reads exact, whole-Agent silences, including expired entries retained by Alertmanager. Monitor-owned silences are not included.

func (*SilenceClient) ListMonitorSilences

func (client *SilenceClient) ListMonitorSilences(ctx context.Context, monitorID string) ([]Silence, error)

ListMonitorSilences reads exact, whole-Monitor silences in native order. An empty monitorID reads silences across all Monitors, including deleted ones. Expired entries remain visible only while retained by Alertmanager.

func (*SilenceClient) ListSilences

func (client *SilenceClient) ListSilences(ctx context.Context) ([]Silence, error)

ListSilences reads whole-Agent and whole-Monitor silences in native order, including retained entries whose owners no longer exist.

type Store

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

Store persists notification destinations in the controller database.

func NewStore

func NewStore(db *sql.DB) *Store

NewStore requires a migrated database. The caller owns its closure.

func (*Store) AlertmanagerConfig

func (store *Store) AlertmanagerConfig(ctx context.Context) (content []byte, returnErr error)

AlertmanagerConfig renders destinations and exact rule-to-channel routes. Alerts without an explicit assignment use the empty default receiver.

func (*Store) Create

func (store *Store) Create(ctx context.Context, value Channel) (Channel, error)

Create validates and persists a channel without overwriting an existing ID.

func (*Store) Delete

func (store *Store) Delete(ctx context.Context, id string) error

Delete removes one channel or returns ErrNotFound.

func (*Store) Get

func (store *Store) Get(ctx context.Context, id string) (Channel, error)

Get reads one channel or returns ErrNotFound.

func (*Store) List

func (store *Store) List(ctx context.Context) (values []Channel, returnErr error)

List reads all channels in stable ID order.

func (*Store) Update

func (store *Store) Update(ctx context.Context, value Channel) (Channel, error)

Update validates and replaces a channel's settings while preserving its ID. It returns ErrNotFound instead of creating an absent channel.

Jump to

Keyboard shortcuts

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