event

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2025 License: MIT Imports: 8 Imported by: 0

README

用户审计

Documentation

Index

Constants

View Source
const (
	// Priority 定义事件的优先级
	Priority = 90
)

Variables

View Source
var (
	AppName = "event"
)

Functions

This section is empty.

Types

type Event

type Event struct {
	Id           string `json:"id" bson:"_id"` // mongodb 中的 _id 表示的是对象 id
	Who          string `json:"who" bson:"who"`
	Time         int64  `json:"time" bson:"time"`
	Ip           string `json:"ip" bson:"ip"`
	UserAgent    string `json:"user_agent" bson:"user_agent"`
	Service      string `json:"service" bson:"service"`     // Service 服务名称 做了什么操作 服务:资源:动作
	Namespace    string `json:"namespace" bson:"namespace"` // Namespace 命名空间
	ResourceType string `json:"resource_type" bson:"resource_type"`
	Action       string `json:"action" bson:"action"` // 操作类型 <list, get, update, create, delete>

	ResourceId   string `json:"resource_id" bson:"resource_id"` // ResourceId 详情信息
	StatusCode   int    `json:"status_code" bson:"status_code"`
	ErrorMessage string `json:"error_message" bson:"error_message"`

	Label  map[string]string `json:"label" bson:"label"`   // Label 标签
	Extras map[string]string `json:"extras" bson:"extras"` // Extras 扩展信息
}

Event 用户操作事件 映射 MongoDB BSON 格式

func NewEvent

func NewEvent() *Event

func (*Event) Load

func (e *Event) Load(data []byte) error

func (*Event) ToKafkaMessage

func (e *Event) ToKafkaMessage() kafka.Message

type QueryEventRequest

type QueryEventRequest struct {
	// 分页参数
	*request.PageRequest
}

func NewQueryEventRequest

func NewQueryEventRequest() *QueryEventRequest

type Service

type Service interface {
	SaveEvent(context.Context, *types.Set[*Event]) error
	QueryEvent(context.Context, *QueryEventRequest) (*types.Set[*Event], error)
}

func GetService

func GetService() Service

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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