Documentation ¶
Index ¶
- type Event
- func (e *Event) Context() context.Context
- func (e *Event) GetMeta(key string) string
- func (e *Event) ParseBody() error
- func (e *Event) SetLevel(l Level)
- func (e *Event) SetMeta(key, value string)
- func (e *Event) SetSource(src string)
- func (e *Event) Validate() error
- func (e *Event) WithContext(ctx context.Context)
- type Level
- type OperateEvent
- type Type
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"` // 事件类型 Source string `bson:"source" json:"source"` // 事件来源, 比如cmdb Level Level `bson:"level" json:"level"` // 事件等级 Meta map[string]string `bson:"label" json:"label"` // 标签 Body interface{} `bson:"body" json:"body"` // 事件数据 // contains filtered or unexported fields }
Event 事件数据结构
func NewOperateEvent ¶ added in v0.4.0
func NewOperateEvent(e *OperateEvent) *Event
NewOperateEvent 实例
func (*Event) WithContext ¶ added in v0.3.4
WithContext 添加上下文
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 OperateEvent ¶ added in v0.4.0
type OperateEvent struct { Session string `bson:"session" json:"session"` // 回话ID Account string `bson:"account" json:"account"` // 操作人 RequestID string `bson:"request_id" json:"request_id"` // 请求ID IPAddress string `bson:"ip_address" json:"ip_address"` // 操作者IP UserAgent string `bson:"user_agent" json:"user_agent"` // 用户UA UserName string `bson:"user_name" json:"user_name"` // 用户名称 UserType string `bson:"user_type" json:"user_type"` // 用户类型 UserDomain string `bson:"user_domain" json:"user_domain"` // 操作的域 ServiceName string `bson:"service_name" json:"service_name"` // 服务名称 FeaturePath string `bson:"feature_path" json:"feature_path"` // 功能路径 ResourceType string `bson:"resource_type" json:"resource_type"` // 资源类型 Action string `bson:"action" json:"action"` // 操作动作 Request interface{} `bson:"request" json:"request,omitempty"` // 事件数据 Response interface{} `bson:"response" json:"response,omitempty"` // 事件数据 }
OperateEvent 事件具体数据
func ParseOperateEventFromBytes ¶ added in v0.4.0
func ParseOperateEventFromBytes(data []byte) (*OperateEvent, error)
ParseOperateEventFromBytes 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.