event

package
v0.3.7 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Body

type Body struct {
	Reason       string      `bson:"reason" json:"reason,omitempty"`     // 触发原因, 比如 创建/删除/绑定/告警/恢复
	Message      string      `bson:"message" json:"message,omitempty"`   // 事件消息,
	ResourceType string      `bson:"resource_type" json:"resource_type"` // 资源类型,
	ResourceUUID string      `bson:"resource_uuid" json:"resource_uuid"` // 资源UUID,
	Data         interface{} `bson:"data" json:"data,omitempty"`         // 事件具体数据
}

Body 事件具体数据

type Event

type Event struct {
	Header
	Body
	// contains filtered or unexported fields
}

Event 事件数据结构

func NewEvent added in v0.3.4

func NewEvent() *Event

NewEvent 实例

func (*Event) Context added in v0.3.4

func (e *Event) Context() context.Context

Context 返回事件的上下文

func (*Event) WithContext added in v0.3.4

func (e *Event) WithContext(ctx context.Context)

WithContext 添加上下文

type Header struct {
	ID     string            `bson:"_id" json:"id,omitempty"`        // 事件ID
	Time   ftime.Time        `bson:"time" json:"time,omitempty"`     // 事件发生时间(毫秒)
	Source string            `bson:"source" json:"source,omitempty"` // 事件来源, 比如cmdb
	Level  Level             `bson:"level" json:"level,omitempty"`   // 事件等级
	Label  map[string]string `bson:"label" json:"label,omitempty"`   // 标签
	Meta   Meta              `bson:"meta" json:"meta,omitempty"`     // 事件的元数据
}

Header 事件元数据

type Level

type Level uint

Level 事件基本

const (
	// Trace (trace)
	Trace Level = iota
	// Debug (debug)
	Debug
	// Info (info)
	Info
	// Warn (warn)
	Warn
	// Error (error)
	Error
	// Critical (critical)
	Critical
	// Disaster (disaster)
	Disaster
)

func ParseLevel added in v0.3.3

func ParseLevel(str string) (Level, error)

ParseLevel Parse Level from string

func (Level) Is added in v0.3.3

func (t Level) Is(target Level) bool

Is todo

func (Level) MarshalJSON added in v0.3.3

func (t Level) MarshalJSON() ([]byte, error)

MarshalJSON todo

func (Level) String added in v0.3.3

func (t Level) String() string

String stringer

func (*Level) UnmarshalJSON added in v0.3.3

func (t *Level) UnmarshalJSON(b []byte) error

UnmarshalJSON todo

type Meta added in v0.3.3

type Meta interface {
	// Put associates the specified value with the specified key. If the map
	// previously contained a mapping for the key, the old value is replaced and
	// returned. The key can be expressed in dot-notation (e.g. x.y) to put a value
	// into a nested map.
	//
	// If you need insert keys containing dots then you must use bracket notation
	// to insert values (e.g. m[key] = value).
	Put(key string, value interface{}) (interface{}, error)
	// Delete deletes the given key from the map.
	Delete(key string) error
	// GetValue 获取值
	Get(key string) (interface{}, error)
}

Meta todo

Jump to

Keyboard shortcuts

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