Documentation ¶
Index ¶
- Constants
- Variables
- func CreateDb() *xorm.Engine
- func CreateTmpDb(setting *setting.Setting) (*xorm.Engine, error)
- type BaseModel
- type Channel
- type CommonMap
- type Host
- func (host *Host) AllList() ([]Host, error)
- func (host *Host) Create() (insertId int16, err error)
- func (host *Host) Delete(id int) (int64, error)
- func (host *Host) Find(id int) error
- func (host *Host) List(params CommonMap) ([]Host, error)
- func (host *Host) NameExists(name string, id int16) (bool, error)
- func (host *Host) Total(params CommonMap) (int64, error)
- func (host *Host) Update(id int, data CommonMap) (int64, error)
- func (host *Host) UpdateBean(id int16) (int64, error)
- type LoginLog
- type Mail
- type MailUser
- type Migration
- type Setting
- func (setting *Setting) CreateChannel(channel string) (int64, error)
- func (setting *Setting) CreateMailUser(username, email string) (int64, error)
- func (setting *Setting) InitBasicField()
- func (setting *Setting) IsChannelExist(channel string) bool
- func (setting *Setting) Mail() (Mail, error)
- func (setting *Setting) RemoveChannel(id int) (int64, error)
- func (setting *Setting) RemoveMailUser(id int) (int64, error)
- func (setting *Setting) Slack() (Slack, error)
- func (setting *Setting) UpdateMail(config, template string) error
- func (setting *Setting) UpdateSlack(url, template string) error
- func (setting *Setting) UpdateWebHook(url, template string) error
- func (setting *Setting) Webhook() (WebHook, error)
- type Slack
- type Status
- type Tags
- type Task
- func (task *Task) ActiveList(page, pageSize int) ([]Task, error)
- func (task *Task) ActiveListByHostId(hostId int16) ([]Task, error)
- func (task *Task) ChildrenExist(id int, childrenId int) bool
- func (task *Task) Create() (insertId int, err error)
- func (task *Task) Delete(id int) (int64, error)
- func (task *Task) DependencyList(params CommonMap) ([]Task, error)
- func (task *Task) Detail(id int) (Task, error)
- func (task *Task) Disable(id int) (int64, error)
- func (task *Task) Enable(id int) (int64, error)
- func (task *Task) GetDependencyTaskList(ids string) ([]Task, error)
- func (task *Task) GetStatus(id int) (Status, error)
- func (task *Task) List(params CommonMap) ([]Task, error)
- func (task *Task) NameExist(name string, id int) (bool, error)
- func (task *Task) TagsList() ([]Tags, error)
- func (task *Task) Total(params CommonMap) (int64, error)
- func (task *Task) Update(id int, data CommonMap) (int64, error)
- func (task *Task) UpdateBean(id int) (int64, error)
- type TaskDependencyStatus
- type TaskHTTPMethod
- type TaskHost
- func (th *TaskHost) Add(taskId int, hostIds []int) error
- func (th *TaskHost) GetHostIdsByTaskId(taskId int) ([]TaskHostDetail, error)
- func (th *TaskHost) GetTaskIdsByHostId(hostId int16) ([]interface{}, error)
- func (th *TaskHost) HostIdExist(hostId int16) (bool, error)
- func (th *TaskHost) Remove(taskId int) error
- type TaskHostDetail
- type TaskLevel
- type TaskLog
- func (taskLog *TaskLog) Clear() (int64, error)
- func (taskLog *TaskLog) Create() (insertId int64, err error)
- func (taskLog *TaskLog) List(params CommonMap) ([]TaskLog, error)
- func (taskLog *TaskLog) Remove(id int) (int64, error)
- func (taskLog *TaskLog) RemoveDay(id int) (int64, error)
- func (taskLog *TaskLog) Total(params CommonMap) (int64, error)
- func (taskLog *TaskLog) Update(id int64, data CommonMap) (int64, error)
- type TaskProtocol
- type TaskType
- type User
- func (user *User) Create() (insertId int, err error)
- func (user *User) Delete(id int) (int64, error)
- func (user *User) Disable(id int) (int64, error)
- func (user *User) EmailExists(email string, uid int) (int64, error)
- func (user *User) Enable(id int) (int64, error)
- func (user *User) Find(id int) error
- func (user *User) List(params CommonMap) ([]User, error)
- func (user *User) Match(username, password string) bool
- func (user *User) Total() (int64, error)
- func (user *User) Update(id int, data CommonMap) (int64, error)
- func (user *User) UpdatePassword(id int, password string) (int64, error)
- func (user *User) UsernameExists(username string, uid int) (int64, error)
- type WebHook
Constants ¶
View Source
const ( Page = 1 // 当前页数 PageSize = 20 // 每页多少条数据 MaxPageSize = 1000 // 每次最多取多少条 )
View Source
const ( SlackCode = "slack" SlackUrlKey = "url" SlackTemplateKey = "template" SlackChannelKey = "channel" )
View Source
const ( MailCode = "mail" MailTemplateKey = "template" MailServerKey = "server" MailUserKey = "user" )
View Source
const ( WebhookCode = "webhook" WebhookTemplateKey = "template" WebhookUrlKey = "url" )
View Source
const DefaultTimeFormat = "2006-01-02 15:04:05"
View Source
const PasswordSaltLength = 6
Variables ¶
View Source
var Db *xorm.Engine
View Source
var TablePrefix = ""
Functions ¶
Types ¶
type Host ¶
type Host struct { Id int16 `json:"id" xorm:"smallint pk autoincr"` Name string `json:"name" xorm:"varchar(64) notnull"` // 主机名称 Alias string `json:"alias" xorm:"varchar(32) notnull default '' "` // 主机别名 Port int `json:"port" xorm:"notnull default 5921"` // 主机端口 Remark string `json:"remark" xorm:"varchar(100) notnull default '' "` // 备注 BaseModel `json:"-" xorm:"-"` Selected bool `json:"-" xorm:"-"` }
主机
type LoginLog ¶
type Setting ¶
type Setting struct { Id int `xorm:"int pk autoincr"` Code string `xorm:"varchar(32) notnull"` Key string `xorm:"varchar(64) notnull"` Value string `xorm:"varchar(4096) notnull default '' "` }
func (*Setting) CreateChannel ¶
创建slack渠道
func (*Setting) CreateMailUser ¶
func (*Setting) IsChannelExist ¶
func (*Setting) RemoveChannel ¶
删除slack渠道
func (*Setting) UpdateMail ¶
func (*Setting) UpdateSlack ¶
func (*Setting) UpdateWebHook ¶
type Task ¶
type Task struct { Id int `json:"id" xorm:"int pk autoincr"` Name string `json:"name" xorm:"varchar(32) notnull"` // 任务名称 Level TaskLevel `json:"level" xorm:"tinyint notnull index default 1"` // 任务等级 1: 主任务 2: 依赖任务 DependencyTaskId string `json:"dependency_task_id" xorm:"varchar(64) notnull default ''"` // 依赖任务ID,多个ID逗号分隔 DependencyStatus TaskDependencyStatus `json:"dependency_status" xorm:"tinyint notnull default 1"` // 依赖关系 1:强依赖 主任务执行成功, 依赖任务才会被执行 2:弱依赖 Spec string `json:"spec" xorm:"varchar(64) notnull"` // crontab Protocol TaskProtocol `json:"protocol" xorm:"tinyint notnull index"` // 协议 1:http 2:系统命令 Command string `json:"command" xorm:"varchar(256) notnull"` // URL地址或shell命令 HttpMethod TaskHTTPMethod `json:"http_method" xorm:"tinyint notnull default 1"` // http请求方法 Timeout int `json:"timeout" xorm:"mediumint notnull default 0"` // 任务执行超时时间(单位秒),0不限制 Multi int8 `json:"multi" xorm:"tinyint notnull default 1"` // 是否允许多实例运行 RetryTimes int8 `json:"retry_times" xorm:"tinyint notnull default 0"` // 重试次数 RetryInterval int16 `json:"retry_interval" xorm:"smallint notnull default 0"` // 重试间隔时间 NotifyStatus int8 `json:"notify_status" xorm:"tinyint notnull default 1"` // 任务执行结束是否通知 0: 不通知 1: 失败通知 2: 执行结束通知 3: 任务执行结果关键字匹配通知 NotifyType int8 `json:"notify_type" xorm:"tinyint notnull default 0"` // 通知类型 1: 邮件 2: slack 3: webhook NotifyReceiverId string `json:"notify_receiver_id" xorm:"varchar(256) notnull default '' "` // 通知接受者ID, setting表主键ID,多个ID逗号分隔 NotifyKeyword string `json:"notify_keyword" xorm:"varchar(128) notnull default '' "` Tag string `json:"tag" xorm:"varchar(32) notnull default ''"` Remark string `json:"remark" xorm:"varchar(100) notnull default ''"` // 备注 Status Status `json:"status" xorm:"tinyint notnull index default 0"` // 状态 1:正常 0:停止 Created time.Time `json:"created" xorm:"datetime notnull created"` // 创建时间 Deleted time.Time `json:"deleted" xorm:"datetime deleted"` // 删除时间 Updated time.Time `json:"updated" xorm:"datetime notnull updated"` // 更新时间 Creator int `json:"creator" xorm:"int notnull default 0"` // 创建者 Updater int `json:"updater" xorm:"int notnull default 0"` // 更新者 BaseModel `json:"-" xorm:"-"` Hosts []TaskHostDetail `json:"hosts" xorm:"-"` NextRunTime time.Time `json:"next_run_time" xorm:"-"` //下次运行时间 Children []Task `json:"children" xorm:"-"` //子任务 LastRunInfo TaskLog `json:"last_run_info" xorm:"-"` //最后执行日志信息 }
任务
func (*Task) ActiveListByHostId ¶
获取某个主机下的所有激活任务
func (*Task) GetDependencyTaskList ¶
获取依赖任务列表
type TaskDependencyStatus ¶
type TaskDependencyStatus int8
const ( TaskDependencyStatusStrong TaskDependencyStatus = 1 // 强依赖 TaskDependencyStatusWeak TaskDependencyStatus = 2 // 弱依赖 )
type TaskHTTPMethod ¶
type TaskHTTPMethod int8
const ( TaskHTTPMethodGet TaskHTTPMethod = 1 TaskHttpMethodPost TaskHTTPMethod = 2 )
type TaskHost ¶
type TaskHost struct { Id int `json:"id" xorm:"int pk autoincr"` TaskId int `json:"task_id" xorm:"int not null index"` HostId int16 `json:"host_id" xorm:"smallint not null index"` }
func (*TaskHost) GetHostIdsByTaskId ¶
func (th *TaskHost) GetHostIdsByTaskId(taskId int) ([]TaskHostDetail, error)
func (*TaskHost) GetTaskIdsByHostId ¶
func (*TaskHost) HostIdExist ¶
判断主机id是否有引用
type TaskHostDetail ¶
type TaskHostDetail struct { TaskHost `xorm:"extends"` Name string `json:"name"` Port int `json:"port"` Alias string `json:"alias"` }
func (TaskHostDetail) TableName ¶
func (TaskHostDetail) TableName() string
type TaskLog ¶
type TaskLog struct { Id int64 `json:"id" xorm:"bigint pk autoincr"` TaskId int `json:"task_id" xorm:"int notnull index default 0"` // 任务id Name string `json:"name" xorm:"varchar(32) notnull"` // 任务名称 Spec string `json:"spec" xorm:"varchar(64) notnull"` // crontab Protocol TaskProtocol `json:"protocol" xorm:"tinyint notnull index"` // 协议 1:http 2:RPC Command string `json:"command" xorm:"varchar(256) notnull"` // URL地址或shell命令 Timeout int `json:"timeout" xorm:"mediumint notnull default 0"` // 任务执行超时时间(单位秒),0不限制 RetryTimes int8 `json:"retry_times" xorm:"tinyint notnull default 0"` // 任务重试次数 Hostname string `json:"hostname" xorm:"varchar(128) notnull default '' "` // RPC主机名,逗号分隔 StartTime time.Time `json:"start_time" xorm:"datetime created"` // 开始执行时间 EndTime time.Time `json:"end_time" xorm:"datetime updated"` // 执行完成(失败)时间 Status Status `json:"status" xorm:"tinyint notnull index default 1"` // 状态 0:执行失败 1:执行中 2:执行完毕 3:任务取消(上次任务未执行完成) 4:异步执行 Result string `json:"result" xorm:"mediumtext notnull "` // 执行结果 TotalTime int `json:"total_time" xorm:"-"` // 执行总时长 BaseModel `json:"-" xorm:"-"` }
任务执行日志
type TaskProtocol ¶
type TaskProtocol int8
const ( TaskHTTP TaskProtocol = iota + 1 // HTTP协议 TaskRPC // RPC方式执行命令 )
type User ¶
type User struct { Id int `json:"id" xorm:"pk autoincr notnull "` Name string `json:"name" xorm:"varchar(32) notnull unique"` // 用户名 Password string `json:"-" xorm:"char(32) notnull "` // 密码 Salt string `json:"-" xorm:"char(6) notnull "` // 密码盐值 Email string `json:"email" xorm:"varchar(50) notnull unique default '' "` // 邮箱 Created time.Time `json:"created" xorm:"datetime notnull created"` Updated time.Time `json:"updated" xorm:"datetime updated"` IsAdmin int8 `json:"is_admin" xorm:"tinyint notnull default 0"` // 是否是管理员 2:超级管理员 1:管理员 0:普通用户 Status Status `json:"status" xorm:"tinyint notnull default 1"` // 1: 正常 0:禁用 BaseModel `json:"-" xorm:"-"` }
用户model
func (*User) EmailExists ¶
邮箱地址是否存在
func (*User) UpdatePassword ¶
Click to show internal directories.
Click to hide internal directories.