Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Event ¶
type Event struct { ID string `bson:"_id" json:"id"` // 事件ID Time ftime.Time `bson:"time" json:"time"` // 事件发生时间(毫秒) Type Type `bson:"type" json:"type"` // 事件类型 *Header `bson:",inline"` // 事件头 Body interface{} `bson:"body" json:"body"` // 事件数据 // contains filtered or unexported fields }
Event 事件数据结构
func NewOperateEvent ¶ added in v0.4.0
func NewOperateEvent(header *Header, e *OperateEvent) *Event
NewOperateEvent 实例
func (*Event) WithContext ¶ added in v0.3.4
WithContext 添加上下文
type Header ¶
type Header struct { Source string `bson:"source" json:"source"` // 事件来源, 比如cmdb Level Level `bson:"level" json:"level"` // 事件等级 Label map[string]string `bson:"label" json:"label"` // 标签 Meta Meta `bson:"meta" json:"meta"` // 事件的元数据 }
Header todo
type Level ¶
type Level uint
Level 事件基本
func ParseLevel ¶ added in v0.3.3
ParseLevel Parse Level from string
func (Level) MarshalJSON ¶ added in v0.3.3
MarshalJSON todo
func (*Level) UnmarshalJSON ¶ added in v0.3.3
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
type OperateEvent ¶ added in v0.4.0
type OperateEvent struct { OperateSession string `bson:"operate_session" json:"operate_session"` // 回话ID OperateUser string `bson:"operate_user" json:"operate_user"` // 操作人 ResourceType string `bson:"resource_type" json:"resource_type"` // 资源类型, ResourceUUID string `bson:"resource_uuid" json:"resource_uuid"` // 资源UUID ResourceName string `bson:"resource_name" json:"resource_name"` // 资源名称 Action string `bson:"action" json:"action"` // 操作 Data interface{} `bson:"data" json:"data,omitempty"` // 事件数据 }
OperateEvent 事件具体数据
func ParseOperateEventFromBytes ¶ added in v0.4.0
func ParseOperateEventFromBytes(data []byte) (*OperateEvent, error)
ParseOperateEventFromBytes todo
type StatusEvent ¶ added in v0.5.6
type StatusEvent 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 ResourceName string `bson:"resource_name" json:"resource_name"` // 资源名称 Data interface{} `bson:"data" json:"data,omitempty"` // 事件数据 }
StatusEvent 事件具体数据
func ParseStatusEventFromBytes ¶ added in v0.5.7
func ParseStatusEventFromBytes(data []byte) (*StatusEvent, error)
ParseStatusEventFromBytes todo
type Type ¶ added in v0.4.0
type Type uint
Type 事件类型
func (Type) MarshalJSON ¶ added in v0.4.0
MarshalJSON todo
func (*Type) UnmarshalJSON ¶ added in v0.4.0
UnmarshalJSON todo
Click to show internal directories.
Click to hide internal directories.