event

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2021 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Level_name = map[int32]string{
		0: "TRACE",
		1: "DEBUG",
		2: "INFO",
		3: "WARN",
		4: "ERROR",
		5: "CRITICAL",
		6: "DISASTER",
	}
	Level_value = map[string]int32{
		"TRACE":    0,
		"DEBUG":    1,
		"INFO":     2,
		"WARN":     3,
		"ERROR":    4,
		"CRITICAL": 5,
		"DISASTER": 6,
	}
)

Enum value maps for Level.

View Source
var (
	Type_name = map[int32]string{
		0: "OPERATE",
		1: "STATUS",
	}
	Type_value = map[string]int32{
		"OPERATE": 0,
		"STATUS":  1,
	}
)

Enum value maps for Type.

View Source
var (
	ContentType_name = map[int32]string{
		0: "PROTOBUF",
		1: "JSON",
	}
	ContentType_value = map[string]int32{
		"PROTOBUF": 0,
		"JSON":     1,
	}
)

Enum value maps for ContentType.

View Source
var File_pb_event_event_proto protoreflect.FileDescriptor

Functions

This section is empty.

Types

type ContentType

type ContentType int32
const (
	// Body采用probuf编码, 默认
	ContentType_PROTOBUF ContentType = 0
	// 采用Json编码
	ContentType_JSON ContentType = 1
)

func ParseContentTypeFromString

func ParseContentTypeFromString(str string) (ContentType, error)

ParseContentTypeFromString Parse ContentType from string

func (ContentType) Descriptor

func (ContentType) Enum

func (x ContentType) Enum() *ContentType

func (ContentType) EnumDescriptor deprecated

func (ContentType) EnumDescriptor() ([]byte, []int)

Deprecated: Use ContentType.Descriptor instead.

func (ContentType) Equal

func (t ContentType) Equal(target ContentType) bool

Equal type compare

func (ContentType) IsIn

func (t ContentType) IsIn(targets ...ContentType) bool

IsIn todo

func (ContentType) MarshalJSON

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

MarshalJSON todo

func (ContentType) Number

func (x ContentType) Number() protoreflect.EnumNumber

func (ContentType) String

func (x ContentType) String() string

func (ContentType) Type

func (*ContentType) UnmarshalJSON

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

UnmarshalJSON todo

type Event

type Event struct {

	// 事件ID
	// @gotags: bson:"_id" json:"id"
	Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id" bson:"_id"`
	// 事件类型
	// @gotags: bson:"type" json:"type"
	Type Type `protobuf:"varint,2,opt,name=type,proto3,enum=mcube.event.Type" json:"type" bson:"type"`
	// 事件头
	// @gotags: bson:"header" json:"header"
	Header *Header `protobuf:"bytes,3,opt,name=header,proto3" json:"header" bson:"header"`
	// data 具体的数据
	// @gotags: bson:"-" json:"body"
	Body *anypb.Any `protobuf:"bytes,4,opt,name=body,proto3" json:"body" bson:"-"`
	// contains filtered or unexported fields
}

Event to be used by controllers.

func NewDefaultEvent

func NewDefaultEvent() *Event

NewDefaultEvent todo

func NewJsonOperateEvent

func NewJsonOperateEvent(e *OperateEventData) (*Event, error)

func NewOperateEvent

func NewOperateEvent(t ContentType, e *OperateEventData) (*Event, error)

NewOperateEvent 实例

func NewProtoOperateEvent

func NewProtoOperateEvent(e *OperateEventData) (*Event, error)

func (*Event) Descriptor deprecated

func (*Event) Descriptor() ([]byte, []int)

Deprecated: Use Event.ProtoReflect.Descriptor instead.

func (*Event) GetBody

func (x *Event) GetBody() *anypb.Any

func (*Event) GetHeader

func (x *Event) GetHeader() *Header

func (*Event) GetId

func (x *Event) GetId() string

func (*Event) GetMetaKey

func (e *Event) GetMetaKey(key string) (string, bool)

GetMetaKey 获取meta信息

func (*Event) GetType

func (x *Event) GetType() Type

func (*Event) ParseBoby

func (e *Event) ParseBoby(body proto.Message) (err error)

DecodeBody 解码body数据

func (*Event) ProtoMessage

func (*Event) ProtoMessage()

func (*Event) ProtoReflect

func (x *Event) ProtoReflect() protoreflect.Message

func (*Event) Reset

func (x *Event) Reset()

func (*Event) SetLevel

func (e *Event) SetLevel(l Level)

SetLevel 设置事件级别

func (*Event) SetMeta

func (e *Event) SetMeta(key, value string)

SetMeta 设置meta信息

func (*Event) SetSource

func (e *Event) SetSource(src string)

SetSource 设置事件来源

func (*Event) String

func (x *Event) String() string

func (*Event) Validate

func (e *Event) Validate() error

Validate 校验事件是否合法

type Header struct {

	// 事件发送时间
	// @gotags: bson:"time" json:"time"
	Time int64 `protobuf:"varint,7,opt,name=time,proto3" json:"time" bson:"time"`
	// 请求ID
	// @gotags: bson:"request_id" json:"request_id"
	RequestId string `protobuf:"bytes,6,opt,name=request_id,json=requestId,proto3" json:"request_id" bson:"request_id"`
	// 事件来源
	// @gotags: bson:"source" json:"source"
	Source string `protobuf:"bytes,1,opt,name=source,proto3" json:"source" bson:"source"`
	// 用户UA
	// @gotags: bson:"user_agent" json:"user_agent"
	UserAgent string `protobuf:"bytes,2,opt,name=user_agent,json=userAgent,proto3" json:"user_agent" bson:"user_agent"`
	// 操作者IP
	// @gotags: bson:"ip_address" json:"ip_address"
	IpAddress string `protobuf:"bytes,3,opt,name=ip_address,json=ipAddress,proto3" json:"ip_address" bson:"ip_address"`
	// 事件等级
	// @gotags: bson:"level" json:"level"
	Level Level `protobuf:"varint,4,opt,name=level,proto3,enum=mcube.event.Level" json:"level" bson:"level"`
	// Body编码格式
	// @gotags: bson:"content_type" json:"content_type"
	ContentType ContentType `` /* 134-byte string literal not displayed */
	// 数据metas
	// @gotags: bson:"meta" json:"meta"
	Meta map[string]string `` /* 151-byte string literal not displayed */
	// contains filtered or unexported fields
}

func NewHeader

func NewHeader() *Header

NewHeader todo

func (*Header) Descriptor deprecated

func (*Header) Descriptor() ([]byte, []int)

Deprecated: Use Header.ProtoReflect.Descriptor instead.

func (*Header) GetContentType

func (x *Header) GetContentType() ContentType

func (*Header) GetIpAddress

func (x *Header) GetIpAddress() string

func (*Header) GetLevel

func (x *Header) GetLevel() Level

func (*Header) GetMeta

func (x *Header) GetMeta() map[string]string

func (*Header) GetRequestId

func (x *Header) GetRequestId() string

func (*Header) GetSource

func (x *Header) GetSource() string

func (*Header) GetTime

func (x *Header) GetTime() int64

func (*Header) GetUserAgent

func (x *Header) GetUserAgent() string

func (*Header) ProtoMessage

func (*Header) ProtoMessage()

func (*Header) ProtoReflect

func (x *Header) ProtoReflect() protoreflect.Message

func (*Header) Reset

func (x *Header) Reset()

func (*Header) String

func (x *Header) String() string

type Level

type Level int32
const (
	Level_TRACE    Level = 0
	Level_DEBUG    Level = 1
	Level_INFO     Level = 2
	Level_WARN     Level = 3
	Level_ERROR    Level = 4
	Level_CRITICAL Level = 5
	Level_DISASTER Level = 6
)

func ParseLevelFromString

func ParseLevelFromString(str string) (Level, error)

ParseLevelFromString Parse Level from string

func (Level) Descriptor

func (Level) Descriptor() protoreflect.EnumDescriptor

func (Level) Enum

func (x Level) Enum() *Level

func (Level) EnumDescriptor deprecated

func (Level) EnumDescriptor() ([]byte, []int)

Deprecated: Use Level.Descriptor instead.

func (Level) Equal

func (t Level) Equal(target Level) bool

Equal type compare

func (Level) IsIn

func (t Level) IsIn(targets ...Level) bool

IsIn todo

func (Level) MarshalJSON

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

MarshalJSON todo

func (Level) Number

func (x Level) Number() protoreflect.EnumNumber

func (Level) String

func (x Level) String() string

func (Level) Type

func (Level) Type() protoreflect.EnumType

func (*Level) UnmarshalJSON

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

UnmarshalJSON todo

type OperateEvent

type OperateEvent struct {

	// 事件ID
	// @gotags: bson:"_id" json:"id"
	Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id" bson:"_id"`
	// 事件保存时间
	// @gotags: bson:"save_at" json:"save_at"
	SaveAt int64 `protobuf:"varint,2,opt,name=save_at,json=saveAt,proto3" json:"save_at" bson:"save_at"`
	// 事件类型
	// @gotags: bson:"type" json:"type"
	Type Type `protobuf:"varint,3,opt,name=type,proto3,enum=mcube.event.Type" json:"type" bson:"type"`
	// 事件头
	// @gotags: bson:"header" json:"header"
	Header *Header `protobuf:"bytes,4,opt,name=header,proto3" json:"header" bson:"header"`
	// 操作事件数据
	// @gotags: bson:"body" json:"body"
	Body *OperateEventData `protobuf:"bytes,5,opt,name=body,proto3" json:"body" bson:"body"`
	// contains filtered or unexported fields
}

func (*OperateEvent) Descriptor deprecated

func (*OperateEvent) Descriptor() ([]byte, []int)

Deprecated: Use OperateEvent.ProtoReflect.Descriptor instead.

func (*OperateEvent) GetBody

func (x *OperateEvent) GetBody() *OperateEventData

func (*OperateEvent) GetHeader

func (x *OperateEvent) GetHeader() *Header

func (*OperateEvent) GetId

func (x *OperateEvent) GetId() string

func (*OperateEvent) GetSaveAt

func (x *OperateEvent) GetSaveAt() int64

func (*OperateEvent) GetType

func (x *OperateEvent) GetType() Type

func (*OperateEvent) ProtoMessage

func (*OperateEvent) ProtoMessage()

func (*OperateEvent) ProtoReflect

func (x *OperateEvent) ProtoReflect() protoreflect.Message

func (*OperateEvent) Reset

func (x *OperateEvent) Reset()

func (*OperateEvent) String

func (x *OperateEvent) String() string

type OperateEventData

type OperateEventData struct {

	// 回话ID
	// @gotags: bson:"session" json:"session"
	Session string `protobuf:"bytes,1,opt,name=session,proto3" json:"session" bson:"session"`
	// 操作人
	// @gotags: bson:"account" json:"account"
	Account string `protobuf:"bytes,2,opt,name=account,proto3" json:"account" bson:"account"`
	// 用户名称
	// @gotags: bson:"user_name" json:"user_name"
	UserName string `protobuf:"bytes,4,opt,name=user_name,json=userName,proto3" json:"user_name" bson:"user_name"`
	// 用户类型
	// @gotags: bson:"user_type" json:"user_type"
	UserType string `protobuf:"bytes,5,opt,name=user_type,json=userType,proto3" json:"user_type" bson:"user_type"`
	// 操作的域
	// @gotags: bson:"user_domain" json:"user_domain"
	UserDomain string `protobuf:"bytes,6,opt,name=user_domain,json=userDomain,proto3" json:"user_domain" bson:"user_domain"`
	// 服务名称
	// @gotags: bson:"service_name" json:"service_name"
	ServiceName string `protobuf:"bytes,7,opt,name=service_name,json=serviceName,proto3" json:"service_name" bson:"service_name"`
	// 功能路径
	// @gotags: bson:"feature_path" json:"feature_path"
	FeaturePath string `protobuf:"bytes,8,opt,name=feature_path,json=featurePath,proto3" json:"feature_path" bson:"feature_path"`
	// 资源类型
	// @gotags: bson:"resource_type" json:"resource_type"
	ResourceType string `protobuf:"bytes,9,opt,name=resource_type,json=resourceType,proto3" json:"resource_type" bson:"resource_type"`
	// 操作动作
	// @gotags: bson:"action" json:"action"
	Action string `protobuf:"bytes,10,opt,name=action,proto3" json:"action" bson:"action"`
	// 操作耗时, 单位毫秒
	// @gotags: bson:"cost" json:"cost"
	Cost int64 `protobuf:"varint,13,opt,name=cost,proto3" json:"cost" bson:"cost"`
	// 事件数据
	// @gotags: bson:"request" json:"request,omitempty"
	Request string `protobuf:"bytes,11,opt,name=request,proto3" json:"request,omitempty" bson:"request"`
	// 事件数据
	// @gotags: bson:"response" json:"response,omitempty"
	Response string `protobuf:"bytes,12,opt,name=response,proto3" json:"response,omitempty" bson:"response"`
	// contains filtered or unexported fields
}

OperateEvent 事件具体数据

func (*OperateEventData) Descriptor deprecated

func (*OperateEventData) Descriptor() ([]byte, []int)

Deprecated: Use OperateEventData.ProtoReflect.Descriptor instead.

func (*OperateEventData) GetAccount

func (x *OperateEventData) GetAccount() string

func (*OperateEventData) GetAction

func (x *OperateEventData) GetAction() string

func (*OperateEventData) GetCost

func (x *OperateEventData) GetCost() int64

func (*OperateEventData) GetFeaturePath

func (x *OperateEventData) GetFeaturePath() string

func (*OperateEventData) GetRequest

func (x *OperateEventData) GetRequest() string

func (*OperateEventData) GetResourceType

func (x *OperateEventData) GetResourceType() string

func (*OperateEventData) GetResponse

func (x *OperateEventData) GetResponse() string

func (*OperateEventData) GetServiceName

func (x *OperateEventData) GetServiceName() string

func (*OperateEventData) GetSession

func (x *OperateEventData) GetSession() string

func (*OperateEventData) GetUserDomain

func (x *OperateEventData) GetUserDomain() string

func (*OperateEventData) GetUserName

func (x *OperateEventData) GetUserName() string

func (*OperateEventData) GetUserType

func (x *OperateEventData) GetUserType() string

func (*OperateEventData) ProtoMessage

func (*OperateEventData) ProtoMessage()

func (*OperateEventData) ProtoReflect

func (x *OperateEventData) ProtoReflect() protoreflect.Message

func (*OperateEventData) Reset

func (x *OperateEventData) Reset()

func (*OperateEventData) String

func (x *OperateEventData) String() string

type Type

type Type int32
const (
	// 全局配置, 所有服务可以读取
	Type_OPERATE Type = 0
	// 组内配置, 组里面的服务可以读取
	Type_STATUS Type = 1
)

func ParseTypeFromString

func ParseTypeFromString(str string) (Type, error)

ParseTypeFromString Parse Type from string

func (Type) Descriptor

func (Type) Descriptor() protoreflect.EnumDescriptor

func (Type) Enum

func (x Type) Enum() *Type

func (Type) EnumDescriptor deprecated

func (Type) EnumDescriptor() ([]byte, []int)

Deprecated: Use Type.Descriptor instead.

func (Type) Equal

func (t Type) Equal(target Type) bool

Equal type compare

func (Type) IsIn

func (t Type) IsIn(targets ...Type) bool

IsIn todo

func (Type) MarshalJSON

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

MarshalJSON todo

func (Type) Number

func (x Type) Number() protoreflect.EnumNumber

func (Type) String

func (x Type) String() string

func (Type) Type

func (Type) Type() protoreflect.EnumType

func (*Type) UnmarshalJSON

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

UnmarshalJSON todo

Jump to

Keyboard shortcuts

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