mgo

package
v0.0.0-...-b1ea8ad Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2020 License: Apache-2.0 Imports: 5 Imported by: 1

Documentation

Index

Constants

View Source
const (
	Coll_JobLog       = "job_log"
	Coll_JobLatestLog = "job_latest_log"
	Coll_Stat         = "stat"
)
View Source
const (
	Coll_Account = "account"
)

Variables

This section is empty.

Functions

func BanAccount

func BanAccount(email string) error

func CleanupLogs

func CleanupLogs(expiration time.Duration)

func CreateAccount

func CreateAccount(u *Account) error

func EnsureAccountIndex

func EnsureAccountIndex() error

func EnsureJobLogIndex

func EnsureJobLogIndex()

func GetJobLatestLogListByJobIds

func GetJobLatestLogListByJobIds(jobIds []string) (m map[string]*JobLatestLog, err error)

func UpdateAccount

func UpdateAccount(query bson.M, change bson.M) error

Types

type Account

type Account struct {
	ID       bson.ObjectId `bson:"_id" json:"id"`
	Role     Role          `bson:"role" json:"role"`
	Email    string        `bson:"email" json:"email"`
	Password string        `bson:"password" json:"password"`
	Salt     string        `bson:"salt" json:"salt"`
	Status   UserStatus    `bson:"status" json:"status"`
	Session  string        `bson:"session" json:"-"`
	// If true, role and status are unchangeable, email and password can be change by it self only.
	Unchangeable bool      `bson:"unchangeable" json:"-"`
	CreateTime   time.Time `bson:"createTime" json:"createTime"`
}

func GetAccountByEmail

func GetAccountByEmail(email string) (u *Account, err error)

func GetAccounts

func GetAccounts(query bson.M) (list []Account, err error)

type JobLatestLog

type JobLatestLog struct {
	JobLog   `bson:",inline"`
	RefLogId string `bson:"refLogId,omitempty" json:"refLogId"`
}

func GetJobLatestLogList

func GetJobLatestLogList(query bson.M, page, size int, sort string) (list []*JobLatestLog, total int, err error)

type JobLog

type JobLog struct {
	Id        bson.ObjectId `bson:"_id,omitempty" json:"id"`
	JobId     string        `bson:"jobId" json:"jobId"`               // 任务 Id,索引
	JobGroup  string        `bson:"jobGroup" json:"jobGroup"`         // 任务分组,配合 Id 跳转用
	User      string        `bson:"user" json:"user"`                 // 执行此次任务的用户
	Name      string        `bson:"name" json:"name"`                 // 任务名称
	Node      string        `bson:"node" json:"node"`                 // 运行此次任务的节点 id,索引
	Hostname  string        `bson:"hostname" json:"hostname"`         // 运行此次任务的节点主机名称,索引
	IP        string        `bson:"ip" json:"ip"`                     // 运行此次任务的节点主机IP,索引
	Command   string        `bson:"command" json:"command,omitempty"` // 执行的命令,包括参数
	Output    string        `bson:"output" json:"output,omitempty"`   // 任务输出的所有内容
	Success   bool          `bson:"success" json:"success"`           // 是否执行成功
	BeginTime time.Time     `bson:"beginTime" json:"beginTime"`       // 任务开始执行时间,精确到毫秒,索引
	EndTime   time.Time     `bson:"endTime" json:"endTime"`           // 任务执行完毕时间,精确到毫秒
	Cleanup   time.Time     `bson:"cleanup,omitempty" json:"-"`       // 日志清除时间标志
}

任务执行记录

func GetJobLogById

func GetJobLogById(id bson.ObjectId) (l *JobLog, err error)

func GetJobLogList

func GetJobLogList(query bson.M, page, size int, sort string) (list []*JobLog, total int, err error)

type Role

type Role int
const (
	Administrator Role = 1
	Developer     Role = 2
	Reporter      Role = 3
)

func (Role) Defined

func (r Role) Defined() bool

func (Role) String

func (r Role) String() string

type StatExecuted

type StatExecuted struct {
	Total     int64  `bson:"total" json:"total"`
	Successed int64  `bson:"successed" json:"successed"`
	Failed    int64  `bson:"failed" json:"failed"`
	Date      string `bson:"date" json:"date"`
}

func JobLogDailyStat

func JobLogDailyStat(begin, end time.Time) (ls []*StatExecuted, err error)

func JobLogStat

func JobLogStat() (s *StatExecuted, err error)

type UserStatus

type UserStatus int
const (
	UserBanned  UserStatus = -1
	UserActived UserStatus = 1
)

func (UserStatus) Defined

func (s UserStatus) Defined() bool

Jump to

Keyboard shortcuts

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