event

package
v0.0.17 Latest Latest
Warning

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

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

README

任务执行中的事件

Documentation

Index

Constants

View Source
const (
	ORDER_BY_DESC = "DESC"
	ORDER_BY_ASC  = "ASC"
)
View Source
const (
	APP_NAME = "task_events"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AddEventRequest

type AddEventRequest struct {
}

type Event

type Event struct {
	// 任务Id
	Id string `json:"id" gorm:"column:id;type:string;primary_key;" unique:"true" description:"Id"`
	// 创建时间
	CreatedAt time.Time `` /* 126-byte string literal not displayed */
	// 事件定义
	EventSpec
}

func NewEvent

func NewEvent(spec EventSpec) *Event

func (*Event) TableName

func (e *Event) TableName() string

type EventSpec

type EventSpec struct {
	// 事件所属资源
	Resource string `json:"resource" gorm:"column:resource;type:varchar(120);" description:"事件所属资源"`
	// 事件发生时间
	Time time.Time `json:"time" gorm:"column:time;type:timestamp;" description:"事件发生时间"`
	// 事件的级别
	Level LEVEL `json:"level" gorm:"column:level;type:tinyint(2);" description:"事件的级别"`
	// 事件信息
	Message string `json:"message" gorm:"column:message;type:text;" description:"事件信息"`
	// 事件详情
	Detail string `json:"detail" gorm:"column:detail;type:text;" description:"事件详情"`
	// 事件标签
	Label map[string]string `json:"label" bson:"label" gorm:"column:label;serializer:json;type:json" description:"事件标签" optional:"true"`
}

func NewEventSpec

func NewEventSpec() *EventSpec

func (*EventSpec) SetDetail added in v0.0.16

func (s *EventSpec) SetDetail(detail string) *EventSpec

func (*EventSpec) SetLabel

func (s *EventSpec) SetLabel(key, value string) *EventSpec

func (*EventSpec) SetLevel

func (s *EventSpec) SetLevel(l LEVEL) *EventSpec

func (*EventSpec) SetMessage

func (s *EventSpec) SetMessage(msg string) *EventSpec

type LEVEL

type LEVEL int
const (
	// DEBUG
	LEVEL_DEBUG LEVEL = iota
	// INFO
	LEVEL_INFO
	// WARN
	LEVEL_WARN
	// ERROR
	LEVEL_ERROR
)

type ORDER_BY

type ORDER_BY string

type QueryEventRequest

type QueryEventRequest struct {
	// 分页参数
	request.PageRequest
	// 事件标签, TaskId
	Label map[string]string `json:"label" bson:"label" description:"事件标签" optional:"true"`
	// 排序方式
	OrderBy ORDER_BY `json:"order_by" bson:"order_by" description:"排序方式" optional:"true"`
}

func NewQueryEventRequest

func NewQueryEventRequest() *QueryEventRequest

func (*QueryEventRequest) SetLabel

func (r *QueryEventRequest) SetLabel(key, value string) *QueryEventRequest

func (*QueryEventRequest) SetOrderBy

func (r *QueryEventRequest) SetOrderBy(orerBy ORDER_BY) *QueryEventRequest

type Service

type Service interface {
	// 添加事件
	AddEvent(context.Context, *EventSpec) (*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