models

package
v0.0.0-...-1e17dab Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HEARTBEAT_SUCCESS = "success"
	HEARTBEAT_FAILED  = "failed"
)
View Source
const (
	MSG_TYPE_REGISTER_MSG        = "registerMsg"
	MSG_TYPE_REGISTER_REPLY_MSG  = "registerReplyMsg"
	MSG_TYPE_HEARTBEAT_MSG       = "heartbeatMsg"
	MSG_TYPE_HEARTBEAT_REPLY_MSG = "heartbeatReplyMsg"
	MSG_TYPE_TASK_MSG            = "taskMsg"
	MSG_TYPE_TASK_REPLY_MSG      = "taskReplyMsg"
)
View Source
const (
	NODE_STATUS_CONNECTING = "connecting"
	NODE_STATUS_ONLINE     = "online"
	NODE_STATUS_OFFLINE    = "offline"
)
View Source
const (
	REGISTER_SUCCESS = "success"
	REGISTER_FAILED  = "failed"
)
View Source
const (
	TASK_TYPE_SHELL   = TaskType("shell")
	TASK_TYPE_GO_FUNC = TaskType("go-func")
	TASK_TYPE_HTTP    = TaskType("http")

	TASK_OPERATION_START = "start"
	TASK_OPERATION_STOP  = "stop"

	TASK_STATUS_NOT_STARTED = "not_started"
	TASK_STATUS_ASSIGNING   = "assigning"
	TASK_STATUS_RUNNING     = "running"
	TASK_STATUS_REASSIGNING = "reassigning"
	TASK_STATUS_DONE        = "done"
)

Variables

View Source
var (
	ErrNodeIdIsEmpty = errors.New("node id is empty")
	ErrNodeIPEmpty   = errors.New("node ip is empty")
	ErrNodeNameEmpty = errors.New("node name is empty")
	ErrNodeExist     = errors.New("node exists")
)
View Source
var (
	ErrTaskIdEmpty        = errors.New("task id is empty")
	ErrTaskNameEmpty      = errors.New("task name is empty")
	ErrTaskExprEmpty      = errors.New("task expr is empty")
	ErrTaskTypeNotSupport = errors.New("task type not support")

	ErrTaskGoFuncNameIsEmpty = errors.New("task go func name is empty")

	ErrTaskShellCommandIsEmpty = errors.New("task shell command is empty")

	ErrTaskHttpURLIsEmpty    = errors.New("task http url is empty")
	ErrTaskHttpMethodIsEmpty = errors.New("task http method is empty")

	ErrTaskNotFound            = errors.New("task not found")
	ErrTaskOperationNotSupport = errors.New("task operation not support")
)

Functions

This section is empty.

Types

type CreateNewNodeCmd

type CreateNewNodeCmd struct {
	NewNode *CreateNode

	Result *Node
}

type CreateNode

type CreateNode struct {
	Name       string    `json:"name"`
	Ip         Ip        `json:"ip"`
	OnlineTime time.Time `json:"onlineTime"`
	Status     string    `json:"status"`
}

type DatabaseConfig

type DatabaseConfig struct {
	Type             string
	ConnectionString string
	User             string
	Password         string
	Host             string
	Name             string
	SchemaName       string
	GroupName        string
	MaxOpenConn      int
	MaxIdleConn      int
	ConnMaxLifetime  int
	LogQueries       bool
	UrlQueryParams   map[string][]string
	SslMode          string
	CaCertPath       string
	ClientKeyPath    string
	ClientCertPath   string

	//sqlite3
	Path      string
	CacheMode string
}

type GenericMsg

type GenericMsg struct {
	Type       string `json:"type"`
	WorkerId   string `json:"workerId"`
	WorkerName string `json:"workerName"`
	Content    string `json:"content"`
}

type GoTaskFuncInfo

type GoTaskFuncInfo struct {
	FuncName   string        `json:"funcName"`
	Parameters []interface{} `json:"parameters"`
}

func (*GoTaskFuncInfo) Scan

func (gtfi *GoTaskFuncInfo) Scan(value interface{}) error

func (GoTaskFuncInfo) Value

func (gtfi GoTaskFuncInfo) Value() (driver.Value, error)

type HeartbeatMsg

type HeartbeatMsg struct {
	Name       string    `json:"workerName"`
	Ip         Ip        `json:"ip"`
	ActiveTime time.Time `json:"activeTime"`
}

func (*HeartbeatMsg) String

func (h *HeartbeatMsg) String() string

type HeartbeatReplyMsg

type HeartbeatReplyMsg struct {
	Name        string    `json:"workerName"`
	Ip          string    `json:"ip"`
	OnlineTime  time.Time `json:"onlineTime"`
	WorkerId    string    `json:"workerId"`
	AccessToken string    `json:"accessToken"`
	Status      string    `json:"status"`
	ErrMsg      string    `json:"errMsg"`
}

type HttpRequestTask

type HttpRequestTask struct {
	URL     string            `json:"url"`
	Method  string            `json:"method"`
	Body    interface{}       `json:"body"`
	Header  map[string]string `json:"header"`
	Timeout int               `json:"timeout"`
}

func (*HttpRequestTask) Scan

func (hrt *HttpRequestTask) Scan(value interface{}) error

func (HttpRequestTask) Value

func (hrt HttpRequestTask) Value() (driver.Value, error)

type Ip

type Ip string

func (Ip) CanBeReached

func (i Ip) CanBeReached() error

func (Ip) String

func (i Ip) String() string

type Node

type Node struct {
	Id         string         `json:"id" gorm:"column:id;primary_key;not null;type:varchar(255)"`
	Name       string         `json:"name"`
	Ip         string         `json:"ip"`
	Status     string         `json:"status"`
	CreatedAt  time.Time      `json:"createdAt"`
	OnlineTime time.Time      `json:"onlineTime"`
	UpdatedAt  time.Time      `json:"updatedAt"`
	DeletedAt  gorm.DeletedAt `json:"deletedAt"`
}

func (*Node) IsAlive

func (n *Node) IsAlive() bool

type NodeQueryCmd

type NodeQueryCmd struct {
	Name   string
	Ip     string
	Status string

	Results []*Node
	Total   int64
}

type RMQ

type RMQ struct {
	Uri string
}

type RegisterMsg

type RegisterMsg struct {
	Name       string    `json:"workerName"`
	Ip         Ip        `json:"ip"`
	OnlineTime time.Time `json:"onlineTime"`
}

func (*RegisterMsg) String

func (rm *RegisterMsg) String() string

type RegisterReplyMsg

type RegisterReplyMsg struct {
	Name        string    `json:"workerName"`
	Ip          string    `json:"ip"`
	OnlineTime  time.Time `json:"onlineTime"`
	WorkerId    string    `json:"workerId"`
	AccessToken string    `json:"accessToken"`
	Status      string    `json:"status"`
	ErrMsg      string    `json:"errMsg"`
}

type ScheduledJob

type ScheduledJob struct {
	Id       string      `json:"id"`
	TaskId   string      `json:"taskId"`
	Expr     string      `json:"expr"`
	Next     time.Time   `json:"next"`
	Last     time.Time   `json:"last"`
	Duration int64       `json:"duration"`
	WorkerId string      `json:"workerId"`
	JobType  string      `json:"jobType"`
	JobInfo  interface{} `json:"jobInfo"`
}

func (ScheduledJob) Marshal

func (s ScheduledJob) Marshal() ([]byte, error)

type SendMsg

type SendMsg struct {
	Type    string `json:"type"`
	Content string `json:"content"`
}

type ShellTaskInfo

type ShellTaskInfo struct {
	Command    string   `json:"command"`
	Parameters []string `json:"parameters"`
}

func (*ShellTaskInfo) Scan

func (sti *ShellTaskInfo) Scan(value interface{}) error

func (ShellTaskInfo) Value

func (sti ShellTaskInfo) Value() (driver.Value, error)

type Task

type Task struct {
	Id               string           `json:"id" gorm:"column:id;primary_key;not null;type:varchar(255)"`
	Name             string           `json:"name"`
	Expr             string           `json:"expr"`
	TaskType         TaskType         `json:"taskType"`
	ShellJobInfo     *ShellTaskInfo   `json:"shellInfo"`
	GoFuncInfo       *GoTaskFuncInfo  `json:"goFuncInfo"`
	HttpRequestTask  *HttpRequestTask `json:"httpRequestTask"`
	SpecificWorkerId string           `json:"specificWorkerId"`
	RetryTimes       int              `json:"retryTimes"`
	RetriedTimes     int              `json:"retriedTimes"`
	Status           string           `json:"status"`
	Result           string           `json:"result"`
	ErrMsg           string           `json:"errMsg"`
}

type TaskCreate

type TaskCreate struct {
	Name            string           `json:"name"`
	Expr            string           `json:"expr"`
	TaskType        TaskType         `json:"taskType"`
	ShellJobInfo    *ShellTaskInfo   `json:"shellInfo"`
	GoFuncInfo      *GoTaskFuncInfo  `json:"goFuncInfo"`
	HttpRequestTask *HttpRequestTask `json:"httpRequestTask"`

	SpecificWorkerId string `json:"specificWorkerId"`
	RetryTimes       int    `json:"retryTimes"`
}

type TaskCreateCommand

type TaskCreateCommand struct {
	*TaskCreate

	CreatorId   string `json:"creatorId"`
	CreatorName string `json:"creatorName"`

	Result *TaskDto
}

type TaskDto

type TaskDto struct {
	*Task
	NextRunTime *time.Time `json:"nextRunTime" gorm:"-"`
}

type TaskQueryCmd

type TaskQueryCmd struct {
	Name     string `form:"name"`
	TaskType string `form:"taskType"`

	MaxResults int    `form:"maxResults"`
	Page       int    `form:"page"`
	Priority   string `form:"priority"`
	Direction  string `form:"direction"`

	Results []*TaskDto
	Total   int64
}

type TaskReplyMsg

type TaskReplyMsg struct {
	TaskId     string    `json:"taskId"`
	WorkerId   string    `json:"workerId"`
	Status     string    `json:"status"`
	StartedAt  time.Time `json:"startedAt"`
	FinishedAt time.Time `json:"finishedAt"`
	ErrMsg     string    `json:"errMsg"`
	Result     string    `json:"result"`
}

func (*TaskReplyMsg) String

func (trm *TaskReplyMsg) String() string

type TaskType

type TaskType string

func (TaskType) String

func (tt TaskType) String() string

type TaskUpdate

type TaskUpdate struct {
	Id               string           `json:"id"`
	Expr             string           `json:"expr"`
	TaskType         TaskType         `json:"taskType"`
	ShellJobInfo     *ShellTaskInfo   `json:"shellInfo"`
	GoFuncInfo       *GoTaskFuncInfo  `json:"goFuncInfo"`
	HttpRequestTask  *HttpRequestTask `json:"httpRequestTask"`
	SpecificWorkerId string           `json:"specificWorkerId"`
	RetryTimes       int              `json:"retryTimes"`
}

type TaskUpdateCommand

type TaskUpdateCommand struct {
	UpdateTask *TaskUpdate

	CreatorId   string `json:"creatorId"`
	CreatorName string `json:"creatorName"`

	Result *TaskDto
}

type UpdateNode

type UpdateNode struct {
	Id         string    `json:"id"`
	Name       string    `json:"name"`
	Ip         Ip        `json:"ip"`
	OnlineTime time.Time `json:"onlineTime"`
	Status     string    `json:"status"`
}

type UpdateNodeCmd

type UpdateNodeCmd struct {
	Node *UpdateNode

	Result *Node
}

Jump to

Keyboard shortcuts

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