relationDB

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2024 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	MigrateTimedTask = []TimedTaskInfo{

		{
			GroupCode: def.TimedUnitedRhinoQueueGroupCode,
			Type:      domain.TaskTypeTiming,
			Name:      "timedJob服务缓存及日志清理",
			Code:      "timedJobClean",
			Params:    fmt.Sprintf(`{"topic":"%s","payload":""}`, topics.TimedJobClean),
			CronExpr:  "1 1 * * *",
			Status:    def.StatusWaitRun,
			Priority:  3,
		},
	}
	MigrateTimedTaskGroup = []TimedTaskGroup{
		{
			Code:     "queueTest",
			Name:     "消息队列测试",
			Type:     domain.TaskGroupTypeQueue,
			SubType:  domain.QueueTypeNatsJs,
			Priority: 9,
		},
		{
			Code:     def.TimedUnitedRhinoQueueGroupCode,
			Name:     "联犀系统定时消息任务组",
			Type:     domain.TaskGroupTypeQueue,
			SubType:  domain.QueueTypeNatsJs,
			Priority: 9,
		},
		{
			Code:     "sqlJsTest",
			Name:     "sqlJs模式测试",
			Type:     domain.TaskGroupTypeSql,
			SubType:  domain.SqlTypeJs,
			Priority: 7,
			Env:      map[string]string{"code": "66666"},
			Config:   `{"database":{"select":{"dsn":"root:password@tcp(localhost:3306)/iThings?charset=utf8mb4&collation=utf8mb4_bin&parseTime=true&loc=Asia%2FShanghai","dbType":"mysql"}}}`,
		},
	}
)

Functions

func Migrate

func Migrate(c conf.Database) (err error)

func ToTaskInfoDo

func ToTaskInfoDo(po *TimedTaskInfo) *domain.TaskInfo

Types

type ExampleFilter

type ExampleFilter struct {
}

type ExampleRepo

type ExampleRepo struct {
	// contains filtered or unexported fields
}

func NewExampleRepo

func NewExampleRepo(in any) *ExampleRepo

func (ExampleRepo) CountByFilter

func (p ExampleRepo) CountByFilter(ctx context.Context, f ExampleFilter) (size int64, err error)

func (ExampleRepo) Delete

func (p ExampleRepo) Delete(ctx context.Context, id int64) error

func (ExampleRepo) DeleteByFilter

func (p ExampleRepo) DeleteByFilter(ctx context.Context, f ExampleFilter) error

func (ExampleRepo) FindByFilter

func (p ExampleRepo) FindByFilter(ctx context.Context, f ExampleFilter, page *stores.PageInfo) ([]*TimedExample, error)

func (ExampleRepo) FindOne

func (p ExampleRepo) FindOne(ctx context.Context, id int64) (*TimedExample, error)

func (ExampleRepo) FindOneByFilter

func (p ExampleRepo) FindOneByFilter(ctx context.Context, f ExampleFilter) (*TimedExample, error)

func (ExampleRepo) Insert

func (p ExampleRepo) Insert(ctx context.Context, data *TimedExample) error

func (ExampleRepo) MultiInsert

func (p ExampleRepo) MultiInsert(ctx context.Context, data []*TimedExample) error

批量插入 LightStrategyDevice 记录

func (ExampleRepo) Update

func (p ExampleRepo) Update(ctx context.Context, data *TimedExample) error

type TaskFilter

type TaskFilter struct {
	IDs       []int64
	Types     []int64
	Status    []int64
	Codes     []string
	GroupCode string
	WithGroup bool
}

type TaskGroupDBConfig

type TaskGroupDBConfig struct {
	DSN    string `json:"dsn"`    //数据库连接串
	DBType string `json:"dbType"` //数据库类型(默认mysql)
}

type TaskGroupFilter

type TaskGroupFilter struct {
	Codes []string
}

type TaskGroupRepo

type TaskGroupRepo struct {
	// contains filtered or unexported fields
}

func NewTaskGroupRepo

func NewTaskGroupRepo(in any) *TaskGroupRepo

func (TaskGroupRepo) CountByFilter

func (p TaskGroupRepo) CountByFilter(ctx context.Context, f TaskGroupFilter) (size int64, err error)

func (TaskGroupRepo) Delete

func (p TaskGroupRepo) Delete(ctx context.Context, id int64) error

func (TaskGroupRepo) DeleteByFilter

func (p TaskGroupRepo) DeleteByFilter(ctx context.Context, f TaskGroupFilter) error

func (TaskGroupRepo) FindByFilter

func (p TaskGroupRepo) FindByFilter(ctx context.Context, f TaskGroupFilter, page *stores.PageInfo) ([]*TimedTaskGroup, error)

func (TaskGroupRepo) FindOne

func (p TaskGroupRepo) FindOne(ctx context.Context, id int64) (*TimedTaskGroup, error)

func (TaskGroupRepo) FindOneByFilter

func (p TaskGroupRepo) FindOneByFilter(ctx context.Context, f TaskGroupFilter) (*TimedTaskGroup, error)

func (TaskGroupRepo) Insert

func (p TaskGroupRepo) Insert(ctx context.Context, data *TimedTaskGroup) error

func (TaskGroupRepo) MultiInsert

func (p TaskGroupRepo) MultiInsert(ctx context.Context, data []*TimedTaskGroup) error

批量插入 LightStrategyDevice 记录

func (TaskGroupRepo) Update

func (p TaskGroupRepo) Update(ctx context.Context, data *TimedTaskGroup) error

type TaskLogFilter

type TaskLogFilter struct {
	GroupCode   string
	TaskCode    string
	CreatedTime *stores.Cmp
}

type TaskLogRepo

type TaskLogRepo struct {
	// contains filtered or unexported fields
}

func NewJobLogRepo

func NewJobLogRepo(in context.Context) *TaskLogRepo

func (TaskLogRepo) CountByFilter

func (p TaskLogRepo) CountByFilter(ctx context.Context, f TaskLogFilter) (size int64, err error)

func (TaskLogRepo) Delete

func (p TaskLogRepo) Delete(ctx context.Context, id int64) error

func (TaskLogRepo) DeleteByFilter

func (p TaskLogRepo) DeleteByFilter(ctx context.Context, f TaskLogFilter) error

func (TaskLogRepo) FindByFilter

func (p TaskLogRepo) FindByFilter(ctx context.Context, f TaskLogFilter, page *stores.PageInfo) ([]*TimedTaskLog, error)

func (TaskLogRepo) FindOne

func (p TaskLogRepo) FindOne(ctx context.Context, id int64) (*TimedTaskLog, error)

func (TaskLogRepo) FindOneByFilter

func (p TaskLogRepo) FindOneByFilter(ctx context.Context, f TaskLogFilter) (*TimedTaskLog, error)

func (TaskLogRepo) Insert

func (p TaskLogRepo) Insert(ctx context.Context, data *TimedTaskLog) error

func (TaskLogRepo) MultiInsert

func (p TaskLogRepo) MultiInsert(ctx context.Context, data []*TimedTaskLog) error

批量插入 LightStrategyDevice 记录

func (TaskLogRepo) Update

func (p TaskLogRepo) Update(ctx context.Context, data *TimedTaskLog) error

type TaskRepo

type TaskRepo struct {
	// contains filtered or unexported fields
}

func NewTaskInfoRepo

func NewTaskInfoRepo(in any) *TaskRepo

func (TaskRepo) CountByFilter

func (p TaskRepo) CountByFilter(ctx context.Context, f TaskFilter) (size int64, err error)

func (TaskRepo) Delete

func (p TaskRepo) Delete(ctx context.Context, id int64) error

func (TaskRepo) DeleteByFilter

func (p TaskRepo) DeleteByFilter(ctx context.Context, f TaskFilter) error

func (TaskRepo) FindByFilter

func (p TaskRepo) FindByFilter(ctx context.Context, f TaskFilter, page *stores.PageInfo) ([]*TimedTaskInfo, error)

func (TaskRepo) FindOne

func (p TaskRepo) FindOne(ctx context.Context, id int64) (*TimedTaskInfo, error)

func (TaskRepo) FindOneByFilter

func (p TaskRepo) FindOneByFilter(ctx context.Context, f TaskFilter) (*TimedTaskInfo, error)

func (TaskRepo) Insert

func (p TaskRepo) Insert(ctx context.Context, data *TimedTaskInfo) error

func (TaskRepo) MultiInsert

func (p TaskRepo) MultiInsert(ctx context.Context, data []*TimedTaskInfo) error

批量插入 LightStrategyDevice 记录

func (TaskRepo) Update

func (p TaskRepo) Update(ctx context.Context, data *TimedTaskInfo) error

func (TaskRepo) UpdateByFilter

func (p TaskRepo) UpdateByFilter(ctx context.Context, data *TimedTaskInfo, f TaskFilter) error

type TimedExample

type TimedExample struct {
	ID int64 `gorm:"column:id;type:bigint;primary_key;AUTO_INCREMENT"` // id编号
}

示例

type TimedTaskGroup

type TimedTaskGroup struct {
	ID       int64             `gorm:"column:id;primary_key"`                                      // 任务组ID
	Code     string            `gorm:"column:code;uniqueIndex:group_code"`                         //任务组编码
	Name     string            `gorm:"column:name;uniqueIndex:group_name"`                         // 组名
	Type     string            `gorm:"column:type"`                                                //组类型:queue(消息队列消息发送)  sql(执行sql) email(邮件发送) http(http请求)
	SubType  string            `gorm:"column:sub_type;default:''"`                                 //组子类型 natsJs nats         normal js
	Priority int64             `gorm:"column:priority"`                                            //组优先级: 6:critical 最高优先级  3: default 普通优先级 1:low 低优先级
	Env      map[string]string `gorm:"column:env;type:json;serializer:json;NOT NULL;default:'{}'"` //环境变量
	/*
		组的配置, sql类型配置格式如下,key若为select,则select默认会选择该配置,exec:exec执行sql默认会选择这个,执行sql的函数也可以指定连接
		database: map[string]TaskGroupDBConfig
	*/
	Config string `gorm:"column:config;type:json;NOT NULL;default:'{}'"` //组的配置
	stores.NoDelTime
	DeletedTime stores.DeletedTime `gorm:"column:deleted_time;default:0;uniqueIndex:group_code;uniqueIndex:group_name"`
}

func (*TimedTaskGroup) TableName

func (t *TimedTaskGroup) TableName() string

type TimedTaskInfo

type TimedTaskInfo struct {
	ID        int64    `gorm:"column:id;primary_key"`                                // 任务ID
	GroupCode string   `gorm:"column:group_code;uniqueIndex:group_task"`             //组编码
	Type      int64    `gorm:"column:type;default:1"`                                //任务类型 1 定时任务 2 延时任务 3 消息队列触发
	Name      string   `gorm:"column:name"`                                          // 任务名称
	Code      string   `gorm:"column:code;uniqueIndex:group_task"`                   //任务编码
	Topics    []string `gorm:"column:topics;type:json;serializer:json;default:'[]'"` //触发topic列表
	Params    string   `gorm:"column:params;type:json;NOT NULL;default:'{}'"`        // 任务参数,延时任务如果没有传任务参数会拿数据库的参数来执行
	CronExpr  string   `gorm:"column:cron_expr"`                                     // cron执行表达式
	Status    int64    `gorm:"column:status"`                                        // 状态
	Priority  int64    `gorm:"column:priority;default:3"`                            //优先级: 10:critical 最高优先级  3: default 普通优先级 1:low 低优先级
	stores.NoDelTime
	DeletedTime stores.DeletedTime `gorm:"column:deleted_time;default:0;uniqueIndex:group_task"`
	Group       *TimedTaskGroup    `gorm:"foreignKey:Code;references:GroupCode"`
}

func (*TimedTaskInfo) TableName

func (t *TimedTaskInfo) TableName() string

type TimedTaskLog

type TimedTaskLog struct {
	ID                  int64     `gorm:"column:id;primary_key"`                         //
	GroupCode           string    `gorm:"column:group_code;index"`                       //组编码
	TaskCode            string    `gorm:"column:task_code;index"`                        //任务编码
	Params              string    `gorm:"column:params;type:json;NOT NULL;default:'{}'"` // 任务参数
	ResultCode          int64     `gorm:"column:result_code;index"`                      //结果code
	ResultMsg           string    `gorm:"column:result_msg"`                             //结果消息
	CreatedTime         time.Time `gorm:"column:created_time;index;sort:desc;default:CURRENT_TIMESTAMP;NOT NULL"`
	*TimedTaskLogSql    `gorm:"embedded;embeddedPrefix:sql_"`
	*TimedTaskLogScript `gorm:"embedded;embeddedPrefix:script_"`
}

func (*TimedTaskLog) TableName

func (t *TimedTaskLog) TableName() string

type TimedTaskLogScript

type TimedTaskLogScript struct {
	ExecLog []*domain.ScriptLog `gorm:"column:exec_log;type:json;serializer:json"` //执行日志
}

type TimedTaskLogSql

type TimedTaskLogSql struct {
	SelectNum int64 `gorm:"column:select_num"` //查询的数量
	ExecNum   int64 `gorm:"column:exec_num"`   //执行的数量
}

Jump to

Keyboard shortcuts

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