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) UpdateMailServer(config string) (int64, error)
- func (setting *Setting) UpdateSlackUrl(url string) (int64, error)
- type Slack
- type Status
- type Task
- func (task *Task) ActiveList() ([]Task, error)
- func (task *Task) ActiveListByHostId(hostId int16) ([]Task, error)
- func (task *Task) Create() (insertId int, err error)
- func (task *Task) CreateTestTask()
- func (task *Task) Delete(id int) (int64, 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) 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 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) 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) (int64, error)
- func (user *User) Enable(id int) (int64, error)
- func (user *User) List() ([]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) (int64, error)
Constants ¶
View Source
const ( Page = 1 // 当前页数 PageSize = 20 // 每页多少条数据 MaxPageSize = 100000 // 每次最多取多少条 )
View Source
const DefaultTimeFormat = "2006-01-02 15:04:05"
View Source
const MailCode = "mail"
View Source
const MailServerKey = "server"
View Source
const MailUserKey = "user"
View Source
const PasswordSaltLength = 6
View Source
const SlackChannelKey = "channel"
View Source
const SlackCode = "slack"
View Source
const SlackUrlKey = "url"
Variables ¶
View Source
var Db *xorm.Engine
View Source
var TablePrefix string = ""
Functions ¶
Types ¶
type Host ¶
type Host struct { Id int16 `xorm:"smallint pk autoincr"` Name string `xorm:"varchar(64) notnull"` // 主机名称 Alias string `xorm:"varchar(32) notnull default '' "` // 主机别名 Port int `xorm:"notnull default 22"` // 主机端口 Remark string `xorm:"varchar(100) notnull default '' "` // 备注 BaseModel `xorm:"-"` Selected bool `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) UpdateMailServer ¶
type Task ¶
type Task struct { Id int `xorm:"int pk autoincr"` Name string `xorm:"varchar(32) notnull"` // 任务名称 Level TaskLevel `xorm:"smallint notnull index default 1"` // 任务等级 1: 主任务 2: 依赖任务 DependencyTaskId string `xorm:"varchar(64) notnull default ''"` // 依赖任务ID,多个ID逗号分隔 DependencyStatus TaskDependencyStatus `xorm:"smallint notnull default 1"` // 依赖关系 1:强依赖 主任务执行成功, 依赖任务才会被执行 2:弱依赖 Spec string `xorm:"varchar(64) notnull"` // crontab Protocol TaskProtocol `xorm:"tinyint notnull index"` // 协议 1:http 2:系统命令 Command string `xorm:"varchar(256) notnull"` // URL地址或shell命令 Timeout int `xorm:"mediumint notnull default 0"` // 任务执行超时时间(单位秒),0不限制 Multi int8 `xorm:"tinyint notnull default 1"` // 是否允许多实例运行 RetryTimes int8 `xorm:"tinyint notnull default 0"` // 重试次数 NotifyStatus int8 `xorm:"smallint notnull default 1"` // 任务执行结束是否通知 0: 不通知 1: 失败通知 2: 执行结束通知 NotifyType int8 `xorm:"smallint notnull default 0"` // 通知类型 1: 邮件 2: slack NotifyReceiverId string `xorm:"varchar(256) notnull default '' "` // 通知接受者ID, setting表主键ID,多个ID逗号分隔 Tag string `xorm:"varchar(32) notnull default ''"` Remark string `xorm:"varchar(100) notnull default ''"` // 备注 Status Status `xorm:"tinyint notnull index default 0"` // 状态 1:正常 0:停止 Created time.Time `xorm:"datetime notnull created"` // 创建时间 Deleted time.Time `xorm:"datetime deleted"` // 删除时间 BaseModel `xorm:"-"` Hosts []TaskHostDetail `xorm:"-"` }
任务
func (*Task) ActiveListByHostId ¶
获取某个主机下的所有激活任务
func (*Task) GetDependencyTaskList ¶ added in v1.2.1
获取依赖任务列表
type TaskDependencyStatus ¶ added in v1.2.1
type TaskDependencyStatus int8
const ( TaskDependencyStatusStrong TaskDependencyStatus = 1 // 强依赖 TaskDependencyStatusWeak TaskDependencyStatus = 2 // 弱依赖 )
type TaskHost ¶
type TaskHost struct { Id int `xorm:"int pk autoincr"` TaskId int `xorm:"int not null index"` HostId int16 `xorm:"smallint not null index"` }
func (*TaskHost) GetHostIdsByTaskId ¶ added in v1.2.1
func (th *TaskHost) GetHostIdsByTaskId(taskId int) ([]TaskHostDetail, error)
func (*TaskHost) GetTaskIdsByHostId ¶ added in v1.2.1
func (*TaskHost) HostIdExist ¶ added in v1.2.1
判断主机id是否有引用
type TaskHostDetail ¶ added in v1.2.1
func (TaskHostDetail) TableName ¶ added in v1.2.1
func (TaskHostDetail) TableName() string
type TaskLog ¶
type TaskLog struct { Id int64 `xorm:"bigint pk autoincr"` TaskId int `xorm:"int notnull index default 0"` // 任务id Name string `xorm:"varchar(32) notnull"` // 任务名称 Spec string `xorm:"varchar(64) notnull"` // crontab Protocol TaskProtocol `xorm:"tinyint notnull index"` // 协议 1:http 2:RPC Command string `xorm:"varchar(256) notnull"` // URL地址或shell命令 Timeout int `xorm:"mediumint notnull default 0"` // 任务执行超时时间(单位秒),0不限制 RetryTimes int8 `xorm:"tinyint notnull default 0"` // 任务重试次数 Hostname string `xorm:"varchar(128) notnull defalut '' "` // RPC主机名,逗号分隔 StartTime time.Time `xorm:"datetime created"` // 开始执行时间 EndTime time.Time `xorm:"datetime updated"` // 执行完成(失败)时间 Status Status `xorm:"tinyint notnull index default 1"` // 状态 0:执行失败 1:执行中 2:执行完毕 3:任务取消(上次任务未执行完成) 4:异步执行 Result string `xorm:"mediumtext notnull defalut '' "` // 执行结果 TotalTime int `xorm:"-"` // 执行总时长 BaseModel `xorm:"-"` }
任务执行日志
type TaskProtocol ¶
type TaskProtocol int8
const ( TaskHTTP TaskProtocol = iota + 1 // HTTP协议 TaskRPC // RPC方式执行命令 )
type User ¶
type User struct { Id int `xorm:"pk autoincr notnull "` Name string `xorm:"varchar(32) notnull unique"` // 用户名 Password string `xorm:"char(32) notnull "` // 密码 Salt string `xorm:"char(6) notnull "` // 密码盐值 Email string `xorm:"varchar(50) notnull unique default '' "` // 邮箱 Created time.Time `xorm:"datetime notnull created"` Updated time.Time `xorm:"datetime updated"` Deleted time.Time `xorm:"datetime deleted"` IsAdmin int8 `xorm:"tinyint notnull default 0"` // 是否是管理员 1:管理员 0:普通用户 Status Status `xorm:"tinyint notnull default 1"` // 1: 正常 0:禁用 BaseModel `xorm:"-"` }
用户model
func (*User) UpdatePassword ¶
Click to show internal directories.
Click to hide internal directories.