service

package
v0.0.0-...-ce64a08 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2024 License: Apache-2.0 Imports: 50 Imported by: 0

Documentation

Index

Constants

View Source
const NotifyMinTimeout = 10 * time.Second

NotifyMinTimeout is the minimum timeout that is set for the context of a call to a notification pipeline.

Variables

View Source
var (
	ErrTenantIDNotFound = errors.New("tenant id not found")
)

Functions

func SilencesDataLoad

func SilencesDataLoad(client *ent.Client) func(ids ...int) ([]*sil.Entry, error)

SilencesDataLoad is a data loader for silences.

func UserIDsFromLabels

func UserIDsFromLabels(set label.LabelSet) ([]int, error)

UserIDsFromLabels returns the user IDs from the labels.

Types

type AlertCallback

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

AlertCallback 是Alert处理回调类,由于消息中心是系统服务,对于alert无法有明显的上下文,因此需要在回调中处理租户时采用的忽略.

func (*AlertCallback) PostDelete

func (a *AlertCallback) PostDelete(alert *alert.Alert)

func (*AlertCallback) PostStore

func (a *AlertCallback) PostStore(alert *alert.Alert, existing bool)

func (*AlertCallback) PreStore

func (a *AlertCallback) PreStore(alert *alert.Alert, existing bool) error

type AlertManager

type AlertManager struct {
	Coordinator     *Coordinator
	NotificationLog notify.NotificationLog
	Silences        *silence.Silences
	Marker          alert.Marker
	Alerts          provider.Alerts
	Dispatcher      *dispatch.Dispatcher
	Inhibitor       *inhibit.Inhibitor
	Silencer        *silence.Silencer
	Subscribe       *UserSubscribe
	DB              *ent.Client
	Peer            *members.Peer
	// contains filtered or unexported fields
}

func NewAlertManager

func NewAlertManager(app *woocoo.App, opts ...AmOption) (*AlertManager, error)

func (*AlertManager) Apply

func (am *AlertManager) Apply(cnf *conf.Configuration) error

func (*AlertManager) Members

func (am *AlertManager) Members() error

func (*AlertManager) Start

func (am *AlertManager) Start(co *Coordinator, config *profile.Config) error

func (*AlertManager) Stop

func (am *AlertManager) Stop()

type AmOption

type AmOption func(*AlertManager)

func WithClient

func WithClient(client *ent.Client) AmOption

func WithPeer

func WithPeer(p *members.Peer) AmOption

type Coordinator

type Coordinator struct {
	ActiveReceivers map[string]int // receiver name -> number of Notifiers
	Template        *template.Template

	// knockout sdk
	KOSdk *api.SDK
	// contains filtered or unexported fields
}

Coordinator helps the Alert Manager collaborate with external components.

func NewCoordinator

func NewCoordinator(cnf *conf.Configuration) *Coordinator

NewCoordinator returns a new coordinator with the given configuration for alert manager. It does not yet load the configuration from file. This is done in `Reload()`.

func (*Coordinator) AddNamedRoute

func (c *Coordinator) AddNamedRoute(input []*profile.Route) error

func (*Coordinator) AddTenantReceiver

func (c *Coordinator) AddTenantReceiver(input []*profile.Receiver) error

func (*Coordinator) GetReceivers

func (c *Coordinator) GetReceivers() []profile.Receiver

func (*Coordinator) ProfileString

func (c *Coordinator) ProfileString() string

func (*Coordinator) Reload

func (c *Coordinator) Reload() error

Reload triggers a configuration reload from file and notifies all configuration change reloadHooks.

func (*Coordinator) ReloadHooks

func (c *Coordinator) ReloadHooks(ss ...func(*profile.Config) error)

ReloadHooks subscribes the given Subscribers to configuration changes.

func (*Coordinator) RemoveNamedRoute

func (c *Coordinator) RemoveNamedRoute(routeNames []string) error

func (*Coordinator) RemoveTenantReceiver

func (c *Coordinator) RemoveTenantReceiver(receiverNames []string) error

func (*Coordinator) ResolveTimeout

func (c *Coordinator) ResolveTimeout() time.Duration

func (*Coordinator) WalkReceivers

func (c *Coordinator) WalkReceivers(visit func(receiver profile.Receiver) error) error

type NlogCallback

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

func (NlogCallback) CreateLog

func (n NlogCallback) CreateLog(ctx context.Context, r *profile.ReceiverKey, gkey string,
	firingAlerts, resolvedAlerts []uint64, expiresAt time.Time) (int, error)

func (NlogCallback) EvictLog

func (n NlogCallback) EvictLog(ctx context.Context, ids []int)

EvictLog evict log from nlog cache. the rule is expireAt > now.so need not do anything

func (NlogCallback) LoadData

func (n NlogCallback) LoadData() ([]*notify.LogEntry, error)

type UserSubscribe

type UserSubscribe struct {
	DB *ent.Client
}

func (*UserSubscribe) SubUsers

func (u *UserSubscribe) SubUsers(ctx context.Context, al *alert.Alert) ([]notify.UserInfo, error)

Directories

Path Synopsis
mem

Jump to

Keyboard shortcuts

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