dao

package
v0.0.0-...-8110dd7 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2020 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HourData = iota
	DayData
	MonthData
)
View Source
const (
	Cron = iota
	Dur
)
View Source
const (
	TaskWorking = iota
	TaskStop
	TaskRemove
)
View Source
const (
	TopicStatusEnable = iota
	TopicStatusDisable
)
View Source
const (
	LdapUser = 1
)

Variables

View Source
var (
	UserNotExist      = errors.New("user not exist")
	InvalidCredential = errors.New("invalid username or password")
	Administration    = "administration"
)

Functions

func CheckPermission

func CheckPermission(u interface{}, sys string) bool

func Init

func Init()

Types

type DepsTree

type DepsTree struct {
	*Task
	Children []*DepsTree
}

type JobResult

type JobResult struct {
	Id           uint   `gorm:"primary_key"`
	JobName      string `json:"job_name"`
	DispatchID   string `json:"dispatch_id"`
	JobCompleted bool
	GroupID      float64   `json:"group_id"`
	AgentNode    string    `json:"agent_node"`
	StartedAt    time.Time `json:"started_at"`
	FinishedAt   time.Time `json:"finished_at"`
	Status       int       `json:"status"`
	Output       string    `json:"output,omitempty" gorm:"column:output_data"`
}

func (JobResult) Count

func (m JobResult) Count(taskID uint64, node, search string) (total int64)

func (JobResult) Get

func (m JobResult) Get(name string) []*JobResult

func (JobResult) Query

func (m JobResult) Query(taskID uint64, node string, page int64, sort string, limit int64, search string) *LogResult

func (JobResult) TableName

func (JobResult) TableName() string

type LogResult

type LogResult struct {
	Log   []*jobLog `json:"log"`
	Count int       `json:"count"`
}

type Machine

type Machine struct {
	ginp.Model
	System string `binding:"required" json:"system" gorm:"unique_index:idx_ip_system"`
	IP     string `json:"ip" gorm:"unique_index:idx_ip_system"`
	Status int    `json:"status"`

	// operator
	Comment  string `binding:"required" json:"comment"`
	Operator string `json:"author"`

	// only for request form
	Cron bool   `json:"cron" gorm:"-"`
	IPs  string `binding:"required" json:"ips" gorm:"-"`
}

func (Machine) Create

func (m Machine) Create() (err error)

func (Machine) Delete

func (m Machine) Delete() (err error)

func (Machine) Get

func (m Machine) Get(id uint64) (v *Machine, err error)

func (Machine) Query

func (m Machine) Query(query *Query) (v []*Machine, err error)

func (Machine) TableName

func (m Machine) TableName() string

type Node

type Node struct {
	Name  string
	Tasks []*Task
}

type Query

type Query struct {
	Keyword  string   `form:"keyword" json:"keyword"`
	System   string   `form:"system" json:"system"`
	Topic    string   `form:"topic" json:"topic"`
	Queue    string   `form:"queue" json:"queue"`
	Count    int      `form:"count" json:"count"`
	Machines []string `form:"machines" json:"machines"`
}

type Queue

type Queue struct {
	ginp.Model
	Name       string `binding:"required" json:"name" gorm:"unique_index"`
	Describe   string `binding:"required" json:"desc" gorm:"column:description"`
	Password   string `binding:"required" json:"password"`
	TopicCount int    `json:"topics"`

	// operator
	Comment  string `binding:"required" json:"comment"`
	Operator string `json:"author"`
}

func (Queue) Create

func (m Queue) Create() error

func (Queue) Delete

func (m Queue) Delete() (err error)

func (Queue) FindAllByIds

func (m Queue) FindAllByIds(ids []int) ([]*Queue, error)

func (Queue) FindAllByNames

func (m Queue) FindAllByNames(names []string) ([]*Queue, error)

func (Queue) FindBlankQueue

func (m Queue) FindBlankQueue() ([]*Queue, error)

func (Queue) Get

func (m Queue) Get(id uint64) (v *Queue, err error)

func (Queue) GetByName

func (m Queue) GetByName(name string) (v *Queue, err error)

func (Queue) Query

func (m Queue) Query(query *Query) (v []*Queue, err error)

func (Queue) TableName

func (m Queue) TableName() string

func (Queue) Update

func (m Queue) Update() error

type QueueHistory

type QueueHistory struct {
	ginp.Model
	Queue        string  `json:"queue" gorm:"index:idx_queue"`
	SuccessCount int64   `json:"success_count"`
	FailCount    int64   `json:"fail_count"`
	AddQps       float64 `json:"add_qps"`

	//
	DataType int `binding:"required" json:"type" form:"type" gorm:"-"`
}

func (QueueHistory) CreateBatch

func (m QueueHistory) CreateBatch(data map[string]*QueueHistory) error

func (QueueHistory) TableName

func (m QueueHistory) TableName() string

type RunType

type RunType struct {
	Value string
	Type  int
	Unit  string
}

func (*RunType) String

func (r *RunType) String() string

type Storage

type Storage struct {
	ginp.Model
	System         string        `json:"system" gorm:"unique_index:idx_system_host_port"`
	Type           string        `json:"type" gorm:"default:'redis'"`
	Host           string        `json:"host" gorm:"unique_index:idx_system_host_port"`
	Port           int           `json:"port" gorm:"unique_index:idx_system_host_port"`
	Password       string        `json:"password"`
	MaxConnNum     int           `json:"max_conn_num" gorm:"default:'100'"`
	MaxIdleNum     int           `json:"max_idle_num" gorm:"default:'100'"`
	MaxIdleSeconds time.Duration `json:"max_idle_seconds" gorm:"default:'3000000000'"`
	Status         int           `json:"status"`
	Describe       string        `json:"desc" gorm:"column:description"`

	// operator
	Comment  string `form:"comment"`
	Operator string `form:"author"`
}

func (Storage) Create

func (m Storage) Create() (err error)

func (Storage) FindAll

func (m Storage) FindAll() (v []*Storage, err error)

func (*Storage) FindOne

func (m *Storage) FindOne(query map[string]string) error

func (Storage) Get

func (m Storage) Get(id uint64) (v *Storage, err error)

func (Storage) Query

func (m Storage) Query(query *Query) (v []*Storage, err error)

func (Storage) TableName

func (m Storage) TableName() string

func (Storage) Update

func (m Storage) Update() error

type System

type System struct {
	ginp.Model
	Name             string `binding:"required" form:"name" json:"name" gorm:"unique_index"`
	Describe         string `binding:"required" form:"desc" json:"desc" gorm:"column:description"`
	MachineCount     int    `json:"machines"`
	StorageCount     int    `json:"storages"`
	TopicCount       int    `json:"topics"`
	CronMachineCount int    `json:"cron_machines"`
	JobCount         int    `json:"jobs"`

	// operator
	Comment  string `form:"comment"`
	Operator string `form:"author"`

	// cron job count
	JobSuccessCount uint64 `json:"job_success_count" gorm:"-"`
	JobFailCount    uint64 `json:"job_fail_count" gorm:"-"`
}

func (System) Create

func (m System) Create() error

func (System) Query

func (m System) Query(_ *Query) (v []*System, err error)

func (System) TableName

func (m System) TableName() string

type Task

type Task struct {
	ginp.Model
	System      string `binding:"required" json:"system"`
	Name        string `binding:"required" json:"name" gorm:"unique_index:task_name"`
	Describe    string `binding:"required" json:"desc" gorm:"column:description"`
	TimeOut     int    `json:"timeout" gorm:"default:500"`
	Concurrency int    `json:"concurrency" gorm:"default:'1'"`
	Executor    int    `json:"executor" gorm:"default:0"`
	GRPCHost    string `json:"grpc_host" gorm:"column:grpc_host"`
	Exec        string `json:"command"`
	RunType     string `json:"scheduler"`
	Status      int    `json:"status" gorm:"default:0"`                        // 0表示开启
	NodeStatus  int    `json:"nodeStatus" gorm:"column:node_status;default:0"` // 0表示正常,1表示无可用节点
	DependOn    string `json:"dependents"`
	Children    string `json:"children"`
	Operator    string `json:"author"`
	EnvVar      string `json:"envs"`
}

func (*Task) Create

func (t *Task) Create() error

func (*Task) Get

func (t *Task) Get(id int64) *Task

func (Task) GetAllWork

func (t Task) GetAllWork() []*Task

func (*Task) GetDepends

func (t *Task) GetDepends() []string

TODO 需要优化

func (Task) GetDepsTree

func (t Task) GetDepsTree() *DepsTree

func (*Task) GetEtcdJobName

func (t *Task) GetEtcdJobName() string

func (*Task) Query

func (t *Task) Query() (v []*Task, err error)

func (Task) TableName

func (t Task) TableName() string

func (*Task) Update

func (t *Task) Update() error

type TaskDetail

type TaskDetail struct {
	*Task
	Nodes map[string]interface{}
}

type TaskTest

type TaskTest struct {
	ginp.Model
	TaskId     uint64
	TaskJobId  string
	Status     int `gorm:"default:1"`
	Result     string
	TaskDetail string `gorm:"type:text"`
	OpUser     string
}

func (TaskTest) Create

func (m TaskTest) Create() error

func (TaskTest) Get

func (m TaskTest) Get(id uint64) *TaskTest

func (TaskTest) TableName

func (TaskTest) TableName() string

type Topic

type Topic struct {
	ginp.Model

	System         string `binding:"required" json:"system"`
	Queue          string `binding:"required" json:"queue" gorm:"unique_index:uix_name_queue_name"`
	Name           string `binding:"required" json:"name" gorm:"unique_index:uix_name_queue_name"`
	Describe       string `binding:"required" json:"desc" gorm:"column:description"`
	ConsumeFile    string `binding:"required" json:"consume"`
	RetryTimes     int    `json:"retry_times" gorm:"default:'3'"`
	MaxQueueLength int    `json:"max_queue_length" gorm:"default:'1000'"`
	RunType        int    `json:"run_type" gorm:"default:'0'"`
	Password       string `json:"password"`
	NumOfWorkers   int    `json:"num_of_workers" gorm:"default:'10'"`
	CgiConfig      string `json:"cgi_config" gorm:"default:'local'"`
	Storage        uint64 `binding:"required" json:"storage"`
	Status         uint8  `json:"status" gorm:"default:0"`
	Alarm          int    `json:"alarm" gorm:"default:200"`
	AlarmRetry     int    `json:"alarm_retry" gorm:"default:100"`
	HttpConfig     string `json:"http_config" gorm:"default:''"`
	TopicConfig    string `json:"topic_config" gorm:"default:''"`

	// operator
	Comment  string `binding:"required" json:"comment"`
	Operator string `json:"author"`
}

func (Topic) Create

func (m Topic) Create() (err error)

func (Topic) Delete

func (m Topic) Delete() (err error)

func (Topic) FindAllByQueues

func (m Topic) FindAllByQueues(queueNames []string) ([]TransModelTopic, error)

func (*Topic) FindOne

func (m *Topic) FindOne(query map[string]string) error

func (Topic) Get

func (m Topic) Get(id uint64) (v *Topic, err error)

func (Topic) GetQueueTopic

func (m Topic) GetQueueTopic() string

func (Topic) Query

func (m Topic) Query(query *Query) (v []*Topic, err error)

func (Topic) Search

func (m Topic) Search(system, queue, topic string, con string) (v []*Topic, err error)

func (Topic) TableName

func (m Topic) TableName() string

func (Topic) Update

func (m Topic) Update() error

type TopicHistory

type TopicHistory struct {
	ginp.Model
	Queue         string `json:"queue" gorm:"unique_index:uix_queue_topic"`
	Topic         string `json:"topic" gorm:"unique_index:uix_queue_topic"`
	Length        int64  `json:"length"`
	RetryLength   int64  `json:"retry_length"`
	TimeoutLength int64  `json:"timeout_length"`

	//
	DataType int `binding:"required" json:"type" form:"type" gorm:"-"`
}

func (TopicHistory) CreateBatch

func (m TopicHistory) CreateBatch(data map[string]*TopicHistory) error

func (TopicHistory) GetQueueTopic

func (m TopicHistory) GetQueueTopic() string

func (TopicHistory) TableName

func (m TopicHistory) TableName() string

type TransModelQueue

type TransModelQueue struct {
	Name     string `json:"name"`
	Desc     string `json:"desc"`
	Password string `json:"password"`
	Comment  string `json:"comment"`
	Topics   []TransModelTopic
}

type TransModelStorage

type TransModelStorage struct {
	SType string `json:"type"`
	Host  string `json:"host"`
	Port  string `json:"port"`
}

type TransModelTopic

type TransModelTopic struct {
	System   string            `json:"system"`
	Queue    string            `json:"queue"`
	Name     string            `json:"name"`
	Desc     string            `json:"desc"`
	Password string            `json:"password"`
	Consume  string            `json:"consume"`
	Comment  string            `json:"comment"`
	Status   string            `json:"status"`
	Storage  TransModelStorage `json:"storage"`
}

type User

type User struct {
	ginp.Model

	Name     string `binding:"required" json:"username" gorm:"unique_index"`
	Password string `json:"password"`
	Email    string `json:"email"`
	Avatar   string `json:"avatar"`
	Type     int    `json:"type"`
	Roles    string `json:"roles"`

	AuthSrc int `json:"-"`
}

func SearchUser

func SearchUser(keyword string) (v []*User, err error)

func (User) Create

func (m User) Create() error

func (User) Delete

func (m User) Delete() (err error)

func (User) Get

func (m User) Get() (v *User, err error)

func (User) GetByID

func (m User) GetByID() (v *User, err error)

func (User) TableName

func (m User) TableName() string

func (User) Update

func (m User) Update() error

Jump to

Keyboard shortcuts

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