Documentation
¶
Index ¶
- Constants
- Variables
- func Connection() (*xorm.Engine, error)
- func CreateLog(model Model, uid string, operation string) error
- func GeneratePassword(password string) ([]byte, error)
- func Migrate() error
- func ValidatePassword(password string, hashed []byte) (bool, error)
- type Log
- type Model
- type Node
- type PasswordResets
- type Pipeline
- type PipelineNodePivot
- type PipelineRecords
- type PipelineTaskPivot
- type Result
- type Seeder
- type Task
- type TaskRecords
- type User
Constants ¶
View Source
const ( ONLINE = "online" OFFLINE = "offline" MASTER = "master" WORKER = "worker" )
View Source
const ( MODESHELL = "shell" MODEHTTP = "http" MODEMAIL = "mail" MODEHOOK = "hook" )
View Source
const DefaultTimeFormat = "2006-01-02 15:04:05"
Variables ¶
View Source
var Engine *xorm.Engine
Functions ¶
func Connection ¶
func GeneratePassword ¶
Types ¶
type Log ¶
type Log struct {
Id int64 `json:"id" xorm:"pk autoincr comment('ID') BIGINT(20)"`
UserId string `json:"user_id" xorm:"not null comment('用户ID') index CHAR(36)"`
Operation string `json:"operation" xorm:"not null comment('操作') VARCHAR(255)"`
Result string `json:"result" xorm:"null comment('结果') LONGTEXT(0)"`
CreatedAt time.Time `json:"created_at" xorm:"not null comment('创建于') created DATETIME"`
}
type Node ¶
type Node struct {
Id string `json:"id" xorm:"not null pk comment('用户ID') CHAR(36)"`
Name string `json:"name" xorm:"not null comment('名称') VARCHAR(255)"`
Host string `json:"host" xorm:"not null comment('主机地址') VARCHAR(255)"`
Port int `json:"port" xorm:"not null comment('端口') SMALLINT(5)"`
Mode string `json:"mode" xorm:"not null comment('节点类型') CHAR(6)"`
Status string `json:"status" xorm:"not null default('connected') comment('状态') VARCHAR(255)"` // 状态
Version string `json:"version" xorm:"not null comment('版本') VARCHAR(255)"` // 版本
Description string `json:"description" xorm:"comment('描述') VARCHAR(255)"` // 描述信息
CreatedAt utils.Time `json:"created_at" xorm:"not null created comment('创建于') DATETIME"` // 创建于
UpdatedAt utils.Time `json:"updated_at" xorm:"not null updated comment('更新于') DATETIME"` // 更新于
Pipelines []*PipelineNodePivot `json:"pipelines" xorm:"-"` // 关联的流水线
}
type PasswordResets ¶
type Pipeline ¶
type Pipeline struct {
Id string `json:"id" validate:"-" xorm:"not null pk comment('ID') CHAR(36)"`
Name string `json:"name" validate:"required" xorm:"not null comment('名称') VARCHAR(255)"`
Description string `json:"description" validate:"-" xorm:"not null comment('描述') VARCHAR(255)"`
Spec string `json:"spec" validate:"required" xorm:"not null comment('定时器') CHAR(64)"`
Status int `json:"status" validate:"numeric" xorm:"not null default 0 comment('状态') TINYINT(1)"`
Finished string `json:"finished" validate:"omitempty,uuid4" xorm:"null comment('成功时执行') CHAR(36)"`
Failed string `json:"failed" validate:"omitempty,uuid4" xorm:"null comment('失败时执行') CHAR(36)"`
Overlap int `json:"overlap" validate:"numeric" xorm:"not null default 0 comment('重复执行') TINYINT(1)"`
CreatedAt utils.Time `json:"created_at" validate:"-" xorm:"not null created comment('创建于') DATETIME"`
UpdatedAt utils.Time `json:"updated_at" validate:"-" xorm:"not null updated comment('更新于') DATETIME"`
Nodes []string `json:"nodes" xorm:"-"`
Steps []*PipelineTaskPivot `json:"steps" xorm:"-"`
Expression *cronexpr.Expression `json:"-" xorm:"-"`
NextTime time.Time `json:"-" xorm:"-"`
FinishedTask *Task `json:"finished_task,omitempty" xorm:"-"`
FailedTask *Task `json:"failed_task,omitempty" xorm:"-"`
}
Pipeline 流水线模型
type PipelineNodePivot ¶
type PipelineNodePivot struct {
Id string `json:"id" xorm:"not null pk comment('ID') CHAR(36)"`
PipelineId string `json:"pipeline_id" validate:"required,uuid4" xorm:"not null index comment('流水线ID') CHAR(36)"`
NodeId string `json:"node_id" validate:"required,uuid4" xorm:"not null index comment('节点ID') CHAR(36)"`
CreatedAt utils.Time `json:"created_at" validate:"-" xorm:"not null created comment('创建于') DATETIME"`
Pipeline *Pipeline `json:"pipeline" xorm:"-"`
}
type PipelineRecords ¶
type PipelineRecords struct {
Id string `json:"id" xorm:"not null pk comment('ID') CHAR(36)"`
PipelineId string `json:"pipeline_id" xorm:"not null comment('流水线ID') index CHAR(36)"`
NodeId string `json:"node_id" xorm:"not null comment('节点ID') index CHAR(36)"`
WorkerName string `json:"worker_name" xorm:"not null comment('节点名称') VARCHAR(255)"`
Spec string `json:"spec" xorm:"comment('定时器') CHAR(64)"`
Status int `json:"status" xorm:"not null default 1 comment('状态') TINYINT(1)"`
Duration int64 `json:"duration" xorm:"not null comment('持续时间') INT(10)"`
BeginWith utils.Time `json:"begin_with" xorm:"not null comment('开始于') DATETIME"`
FinishWith utils.Time `json:"finish_with" xorm:"not null comment('结束于') DATETIME"`
CreatedAt utils.Time `json:"created_at" validate:"-" xorm:"not null created comment('创建于') DATETIME"`
UpdatedAt utils.Time `json:"updated_at" validate:"-" xorm:"not null updated comment('更新于') DATETIME"`
Steps []*TaskRecords `json:"steps" xorm:"-"`
}
流水线调度记录模型
func (*PipelineRecords) Store ¶ added in v0.4.0
func (records *PipelineRecords) Store() error
保存流水线记录
func (*PipelineRecords) ToString ¶ added in v0.4.0
func (records *PipelineRecords) ToString() (string, error)
序列化
func (*PipelineRecords) Update ¶ added in v0.4.0
func (records *PipelineRecords) Update() error
更新记录
type PipelineTaskPivot ¶
type PipelineTaskPivot struct {
Id string `json:"id" xorm:"not null pk comment('ID') CHAR(36)"`
PipelineId string `json:"pipeline_id" validate:"required,uuid4" xorm:"not null comment('ID') index CHAR(36)"`
TaskId string `json:"task_id" validate:"required,uuid4" xorm:"not null comment('ID') index CHAR(36)"`
Step int `json:"step" validate:"numeric" xorm:"not null comment('步骤') SMALLINT(5)"`
Timeout int `json:"timeout" validate:"numeric" xorm:"not null default 0 comment('超时时间') INT(10)"`
Interval int `json:"interval" validate:"numeric" xorm:"not null default 0 comment('间隔时间') INT(10)"`
Retries int `json:"retries" validate:"numeric" xorm:"not null default 0 comment('重试次数') TINYINT(3)"`
Directory string `json:"directory" validate:"omitempty" xorm:"null comment('工作目录') VARCHAR(255)"`
User string `json:"user" validate:"omitempty" xorm:"null comment('运行用户') VARCHAR(255)"`
Environment string `json:"environment" validate:"omitempty" xorm:"null comment('环境变量') VARCHAR(255)"`
Dependence string `json:"dependence" validate:"required" xorm:"not null default 'strong' comment('依赖') VARCHAR(255)"`
CreatedAt utils.Time `json:"created_at" validate:"-" xorm:"not null created comment('创建于') DATETIME"`
UpdatedAt utils.Time `json:"updated_at" validate:"-" xorm:"not null updated comment('更新于') DATETIME"`
Task *Task `json:"task" validate:"-" xorm:"-"`
}
func (*PipelineTaskPivot) Destroy ¶
func (pivot *PipelineTaskPivot) Destroy() error
Delete a pipeline relation
type Result ¶ added in v0.4.0
type Result struct {
Pipeline *PipelineRecords // 流水线执行记录
Steps []*TaskRecords // 流水线中任务执行记录
}
流水线执行结果
type Task ¶
type Task struct {
Id string `json:"id" validate:"-" xorm:"not null pk comment('用户ID') CHAR(36)"`
Name string `json:"name" validate:"required" xorm:"not null comment('名称') VARCHAR(255)"`
Mode string `json:"mode" validate:"required" xorm:"not null default('shell') comment('任务模式') VARCHAR(32)"`
Url string `json:"url" validate:"omitempty" xorm:"null comment('请求URL') VARCHAR(255)"`
Method string `json:"method" validate:"omitempty" xorm:"null comment('任务模式') VARCHAR(255)"`
Content string `json:"content" validate:"omitempty" xorm:"null comment('内容') TEXT"`
Description string `json:"description" validate:"-" xorm:"null comment('描述') VARCHAR(255)"`
CreatedAt utils.Time `json:"created_at" validate:"-" xorm:"not null created comment('创建于') DATETIME"`
UpdatedAt utils.Time `json:"updated_at" validate:"-" xorm:"not null updated comment('更新于') DATETIME"`
}
Task 任务模型
type TaskRecords ¶
type TaskRecords struct {
Id int64 `json:"id" xorm:"pk autoincr comment('ID') BIGINT(20)"`
PipelineRecordId string `json:"pipeline_record_id" xorm:"not null comment('流水线记录ID') index CHAR(36)"`
TaskId string `json:"task_id" xorm:"not null comment('任务ID') index CHAR(36)"`
NodeId string `json:"node_id" xorm:"not null comment('节点ID') index CHAR(36)"`
TaskName string `json:"task_name" xorm:"not null comment('任务名称') VARCHAR(255)"`
WorkerName string `json:"worker_name" xorm:"not null comment('节点名称') VARCHAR(255)"`
Content string `json:"content" xorm:"not null comment('执行内容') TEXT"`
Mode string `json:"mode" xorm:"not null comment('执行方式') VARCHAR(255)"`
Timeout int `json:"timeout" xorm:"not null default 0 comment('超时时间') INT(10)"`
Retries int `json:"retries" xorm:"not null default 0 comment('重试次数') TINYINT(3)"`
Status string `json:"status" xorm:"not null default 'finished' comment('状态') VARCHAR(255)"`
Result string `json:"result" xorm:"not null comment('执行结果') TEXT"`
Duration int64 `json:"duration" xorm:"not null comment('持续时间') INT(10)"`
BeginWith utils.Time `json:"begin_with" xorm:"not null comment('开始于') DATETIME"`
FinishWith utils.Time `json:"finish_with" xorm:"not null comment('结束于') DATETIME"`
CreatedAt utils.Time `json:"created_at" xorm:"not null comment('创建于') DATETIME"`
}
func (*TaskRecords) ToString ¶ added in v0.4.0
func (records *TaskRecords) ToString() (string, error)
序列化
type User ¶
type User struct {
Id string `json:"id" xorm:"not null pk comment('用户ID') CHAR(36)"`
Name string `json:"name" xorm:"not null comment('姓名') VARCHAR(255)"`
Email string `json:"email" xorm:"not null comment('邮箱') unique VARCHAR(255)"`
Password string `json:"-" xorm:"not null comment('密码') VARCHAR(255)"`
Manager bool `json:"manager" xorm:"not null default 0 comment('管理员') TINYINT(1)"`
CreatedAt utils.Time `json:"created_at" xorm:"not null created comment('创建于') DATETIME"`
UpdatedAt utils.Time `json:"updated_at" xorm:"not null updated comment('更新于') DATETIME"`
}
Click to show internal directories.
Click to hide internal directories.