switcher

package
v1.21.2 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2022 License: Apache-2.0 Imports: 13 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 {
	Status       string            `json:"status"`
	Labels       map[string]string `json:"labels"`
	Annotations  map[string]string `json:"annotations"`
	StartsAt     *time.Time        `json:"startsAt"`
	EndsAt       *time.Time        `json:"endsAt"`
	GeneratorURL string            `json:"generatorURL"`
	Fingerprint  string            `json:"fingerprint"`
}

func (*Alert) AlertName

func (a *Alert) AlertName() string

func (*Alert) Detail

func (a *Alert) Detail() string

type MessageSwitcher

type MessageSwitcher struct {
	DataBase *database.Database
	Users    []*NotifyUser
}

func NewMessageSwitch

func NewMessageSwitch(_ context.Context, db *database.Database) *MessageSwitcher

func (*MessageSwitcher) DeRegistUser

func (ms *MessageSwitcher) DeRegistUser(user *NotifyUser)

func (*MessageSwitcher) DispatchMessage

func (ms *MessageSwitcher) DispatchMessage(msg *msgbus.NotifyMessage)

func (*MessageSwitcher) RegistUser

func (ms *MessageSwitcher) RegistUser(user *NotifyUser)

func (*MessageSwitcher) Send

func (ms *MessageSwitcher) Send(user *NotifyUser, msg *msgbus.NotifyMessage) error

func (*MessageSwitcher) SendMessageToUser

func (ms *MessageSwitcher) SendMessageToUser(msg *msgbus.NotifyMessage, userid uint)

type NotifyUser

type NotifyUser struct {
	Username     string
	UserID       uint
	RWLock       sync.RWMutex
	CurrentWatch map[string]map[string][]string
	Conn         *websocket.Conn

	SessionID string
	// contains filtered or unexported fields
}

func NewNotifyUser

func NewNotifyUser(conn *websocket.Conn, username string, userid uint) *NotifyUser

func (*NotifyUser) CloseConn

func (nu *NotifyUser) CloseConn()

func (*NotifyUser) IsWatchObject

func (nu *NotifyUser) IsWatchObject(msg *msgbus.NotifyMessage) bool

func (*NotifyUser) Read

func (nu *NotifyUser) Read(into interface{}) error

func (*NotifyUser) SetCurrentWatch

func (nu *NotifyUser) SetCurrentWatch(w map[string]map[string][]string)

func (*NotifyUser) Write

func (nu *NotifyUser) Write(data interface{}) error

type ResID

type ResID struct {
	ClusterID       uint
	EnvironmentID   uint
	EnvironmentName string
	ProjectID       uint
	ProjectName     string
	TenantID        uint
	TenantName      string
}

type WebhookAlert

type WebhookAlert struct {
	Receiver          string            `json:"receiver"`
	Status            string            `json:"status"`
	Alerts            []Alert           `json:"alerts"`
	GroupLabels       map[string]string `json:"groupLabels"`
	CommonLabels      map[string]string `json:"commonLabels"`
	CommonAnnotations map[string]string `json:"commonAnnotations"`
	ExternalURL       string            `json:"externalURL"`
	Version           string            `json:"version"`
	GroupKey          string            `json:"groupKey"`
	TruncatedAlerts   int64             `json:"truncatedAlerts"`
	DataBase          *database.Database
}

func (*WebhookAlert) GetAlertUsers

func (w *WebhookAlert) GetAlertUsers(pos database.AlertPosition) map[uint]struct{}

map 效率更高

Jump to

Keyboard shortcuts

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