connector

package
v0.0.0-...-03ffade Latest Latest
Warning

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

Go to latest
Published: May 27, 2024 License: MIT Imports: 10 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Send

func Send(ctx context.Context, servers []string, token string, meta map[string]interface{}, tags []string, origin string, ctl extension.EventControl, message string) error

Send send a message to adanos servers

Types

type Connector

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

Connector 是一个连接器对象,用于创建于 Adanos-alert 的连接

func NewConnector

func NewConnector(token string, servers ...string) *Connector

NewConnector create a new connector

func (*Connector) Send

func (conn *Connector) Send(ctx context.Context, evt *Event) error

Send send a message to adanos server

type Event

type Event struct {
	Meta    map[string]interface{} `json:"meta" yaml:"meta"`
	Tags    []string               `json:"tags" yaml:"tags"`
	Origin  string                 `json:"origin" yaml:"origin"`
	Ctl     EventControl           `json:"ctl" yaml:"ctl"`
	Content string                 `json:"content" yaml:"content"`
}

Event is a adanos alert message

func NewEvent

func NewEvent(content string) *Event

NewEvent create a new Event

func (*Event) WithCtl

func (m *Event) WithCtl(ctl EventControl) *Event

func (*Event) WithMeta

func (m *Event) WithMeta(key string, value interface{}) *Event

func (*Event) WithMetas

func (m *Event) WithMetas(metas map[string]interface{}) *Event

func (*Event) WithOrigin

func (m *Event) WithOrigin(origin string) *Event

func (*Event) WithTags

func (m *Event) WithTags(tags ...string) *Event

type EventControl

type EventControl struct {
	ID              string `json:"id"`               // 消息标识,用于去重
	InhibitInterval string `json:"inhibit_interval"` // 抑制周期,周期内相同 ID 的消息直接丢弃
	RecoveryAfter   string `json:"recovery_after"`   // 自动恢复周期,该事件后一直没有发生相同标识的 消息,则自动生成一条恢复消息
}

Jump to

Keyboard shortcuts

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