biz

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ExecRunning = "running"
	ExecFail    = "fail"
	ExecCancel  = "cancel"
	ExecSuccess = "success"
)
View Source
const (
	WorkerRunning  = "running"
	WorkerEnabled  = true
	WorkerDisabled = false
)
View Source
const (
	ExecTypeGroup = "group"
)

Variables

View Source
var (
	TaskEnabled  = proto.Bool(true)
	TaskDisabled = proto.Bool(false)
)

Functions

This section is empty.

Types

type Log

type Log struct {
	ID             uint32 `json:"id"`
	Uuid           string `json:"uuid"`
	WorkerId       uint32 `json:"worker_id"`
	WorkerSnapshot string `json:"worker_snapshot"`
	TaskId         uint32 `json:"task_id"`
	TaskSnapshot   string `json:"task_snapshot"`
	Start          int64  `json:"start"`
	End            int64  `json:"end"`
	Content        string `json:"content"`
	Status         string `json:"status"`
}

type LogRepo

type LogRepo interface {
	AddLog(ctx kratosx.Context, in *Log) (uint32, error)
	GetLog(ctx kratosx.Context, id uint32) (*Log, error)
	PageLog(ctx kratosx.Context, req *PageLogRequest) ([]*Log, uint32, error)
	AppendLogContent(ctx kratosx.Context, uuid string, c string) error
	UpdateLogStatus(ctx kratosx.Context, uuid string, err error) error
	TaskIsRunning(ctx kratosx.Context, uuid string) bool
}

type LogUseCase

type LogUseCase struct {
	// contains filtered or unexported fields
}

func NewLogUseCase

func NewLogUseCase(config *conf.Config, repo LogRepo) *LogUseCase

NewLogUseCase 创建UseCase实体

func (*LogUseCase) GetLog

func (u *LogUseCase) GetLog(ctx kratosx.Context, id uint32) (*Log, error)

GetLog 获取分页工作节点

func (*LogUseCase) PageLog

func (u *LogUseCase) PageLog(ctx kratosx.Context, req *PageLogRequest) ([]*Log, uint32, error)

PageLog 获取分页工作节点

type PageLogRequest

type PageLogRequest struct {
	Page     uint32 `json:"page"`
	PageSize uint32 `json:"page_size"`
	TaskId   uint32 `json:"task_id"`
}

type PageTaskRequest

type PageTaskRequest struct {
	Page     uint32  `json:"page"`
	PageSize uint32  `json:"page_size"`
	Tag      *string `json:"tag"`
	Status   *string `json:"status"`
	Name     *string `json:"name"`
}

type PageWorkerGroupRequest

type PageWorkerGroupRequest struct {
	Page     uint32 `json:"page"`
	PageSize uint32 `json:"page_size"`
}

type PageWorkerRequest

type PageWorkerRequest struct {
	Page     uint32  `json:"page"`
	PageSize uint32  `json:"page_size"`
	Name     *string `json:"name"`
	GroupId  *uint32 `json:"group_id"`
}

type Task

type Task struct {
	ktypes.BaseModel
	GroupId       uint32     `json:"group_id"`
	Name          string     `json:"name"`
	Tag           string     `json:"tag"`
	Spec          string     `json:"spec"`
	SelectType    string     `json:"select_type"`
	WorkerGroupId *uint32    `json:"worker_group_id"`
	WorkerId      *uint32    `json:"worker_id"`
	ExecType      string     `json:"exec_type"`
	ExecValue     string     `json:"exec_value"`
	ExpectCode    *uint32    `json:"expect_code"`
	RetryCount    *uint32    `json:"retry_count"`
	RetryWaitTime *uint32    `json:"retry_wait_time"`
	MaxExecTime   *uint32    `json:"max_exec_time"`
	Status        *bool      `json:"status"`
	Version       string     `json:"version"`
	Description   string     `json:"description"`
	Group         *TaskGroup `json:"group"`
}

type TaskFactory

type TaskFactory interface {
	DrySpec(s string) bool
	AddCron(id uint32, spec string) error
	UpdateCron(id uint32, spec string) error
	RemoveCron(id uint32) error
	Scheduler(id uint32) error
}

type TaskGroup

type TaskGroup struct {
	ktypes.BaseModel
	Name        string `json:"name"`
	Description string `json:"description"`
}

type TaskRepo

type TaskRepo interface {
	AddTaskGroup(ctx kratosx.Context, in *TaskGroup) (uint32, error)
	AllTaskGroup(ctx kratosx.Context) ([]*TaskGroup, error)
	UpdateTaskGroup(ctx kratosx.Context, c *TaskGroup) error
	DeleteTaskGroup(ctx kratosx.Context, id uint32) error

	GetSpecs(ctx kratosx.Context) map[uint32]string
	AddTask(ctx kratosx.Context, in *Task) (uint32, error)
	GetTask(ctx kratosx.Context, id uint32) (*Task, error)
	GetWorkerByUuid(ctx kratosx.Context, uuid string) (*Worker, error)
	PageTask(ctx kratosx.Context, req *PageTaskRequest) ([]*Task, uint32, error)
	UpdateTask(ctx kratosx.Context, c *Task) error
	DeleteTask(ctx kratosx.Context, id uint32) error
	CancelTask(ctx kratosx.Context, uuid string) error
	UpdateTaskStatus(ctx kratosx.Context, id uint32, status *bool) error
}

type TaskUseCase

type TaskUseCase struct {
	// contains filtered or unexported fields
}

func NewTaskUseCase

func NewTaskUseCase(config *conf.Config, repo TaskRepo, factory TaskFactory) *TaskUseCase

NewTaskUseCase 创建UseCase实体

func (*TaskUseCase) AddTask

func (u *TaskUseCase) AddTask(ctx kratosx.Context, task *Task) (uint32, error)

AddTask 添加任务

func (*TaskUseCase) AddTaskGroup

func (u *TaskUseCase) AddTaskGroup(ctx kratosx.Context, tg *TaskGroup) (uint32, error)

AddTaskGroup 添加任务分组

func (*TaskUseCase) AllTaskGroup

func (u *TaskUseCase) AllTaskGroup(ctx kratosx.Context) ([]*TaskGroup, error)

AllTaskGroup 获取全部任务分组

func (*TaskUseCase) CancelTask

func (u *TaskUseCase) CancelTask(ctx kratosx.Context, uuid string) error

CancelTask 取消执行任务

func (*TaskUseCase) DeleteTask

func (u *TaskUseCase) DeleteTask(ctx kratosx.Context, id uint32) error

DeleteTask 删除指定任务

func (*TaskUseCase) DeleteTaskGroup

func (u *TaskUseCase) DeleteTaskGroup(ctx kratosx.Context, id uint32) error

DeleteTaskGroup 删除指定任务分组

func (*TaskUseCase) DisableTask

func (u *TaskUseCase) DisableTask(ctx kratosx.Context, id uint32) error

DisableTask 禁用指定任务

func (*TaskUseCase) EnableTask

func (u *TaskUseCase) EnableTask(ctx kratosx.Context, id uint32) error

EnableTask 启动指定任务

func (*TaskUseCase) ExecTask

func (u *TaskUseCase) ExecTask(ctx kratosx.Context, id uint32) error

ExecTask 执行任务

func (*TaskUseCase) PageTask

func (u *TaskUseCase) PageTask(ctx kratosx.Context, req *PageTaskRequest) ([]*Task, uint32, error)

PageTask 获取分页任务

func (*TaskUseCase) UpdateTask

func (u *TaskUseCase) UpdateTask(ctx kratosx.Context, task *Task) error

UpdateTask 修改指定任务

func (*TaskUseCase) UpdateTaskGroup

func (u *TaskUseCase) UpdateTaskGroup(ctx kratosx.Context, tg *TaskGroup) error

UpdateTaskGroup 删除指定任务分组

type Worker

type Worker struct {
	ktypes.BaseModel
	GroupId     *uint32      `json:"group_id"`
	Name        string       `json:"name"`
	IP          string       `json:"ip"`
	Status      *bool        `json:"status"`
	Description string       `json:"description"`
	Group       *WorkerGroup `json:"group"`
}

type WorkerFactory

type WorkerFactory interface {
	CheckIP(ctx kratosx.Context, ip string) error
}

type WorkerGroup

type WorkerGroup struct {
	ktypes.BaseModel
	Name        string `json:"name"`
	Description string `json:"description"`
}

type WorkerRepo

type WorkerRepo interface {
	AddWorkerGroup(ctx kratosx.Context, in *WorkerGroup) (uint32, error)
	AllWorkerGroup(ctx kratosx.Context) ([]*WorkerGroup, error)
	UpdateWorkerGroup(ctx kratosx.Context, c *WorkerGroup) error
	DeleteWorkerGroup(ctx kratosx.Context, id uint32) error

	GetWorkerByGroupId(ctx kratosx.Context, id uint32) (*Worker, error)
	AddWorker(ctx kratosx.Context, in *Worker) (uint32, error)
	GetWorker(ctx kratosx.Context, id uint32) (*Worker, error)
	PageWorker(ctx kratosx.Context, req *PageWorkerRequest) ([]*Worker, uint32, error)
	UpdateWorker(ctx kratosx.Context, c *Worker) error
	DeleteWorker(ctx kratosx.Context, id uint32) error
	EnableWorker(ctx kratosx.Context, id uint32) error
	DisableWorker(ctx kratosx.Context, id uint32) error
}

type WorkerUseCase

type WorkerUseCase struct {
	// contains filtered or unexported fields
}

func NewWorkerUseCase

func NewWorkerUseCase(config *conf.Config, repo WorkerRepo, factory WorkerFactory) *WorkerUseCase

NewWorkerUseCase 创建UseCase实体

func (*WorkerUseCase) AddWorker

func (u *WorkerUseCase) AddWorker(ctx kratosx.Context, worker *Worker) (uint32, error)

AddWorker 添加工作节点

func (*WorkerUseCase) AddWorkerGroup

func (u *WorkerUseCase) AddWorkerGroup(ctx kratosx.Context, tg *WorkerGroup) (uint32, error)

AddWorkerGroup 添加节点分组

func (*WorkerUseCase) AllWorkerGroup

func (u *WorkerUseCase) AllWorkerGroup(ctx kratosx.Context) ([]*WorkerGroup, error)

AllWorkerGroup 获取全部节点分组

func (*WorkerUseCase) DeleteWorker

func (u *WorkerUseCase) DeleteWorker(ctx kratosx.Context, id uint32) error

DeleteWorker 删除指定工作节点

func (*WorkerUseCase) DeleteWorkerGroup

func (u *WorkerUseCase) DeleteWorkerGroup(ctx kratosx.Context, id uint32) error

DeleteWorkerGroup 删除指定节点分组

func (*WorkerUseCase) DisableWorker

func (u *WorkerUseCase) DisableWorker(ctx kratosx.Context, id uint32) error

DisableWorker 禁用指定工作节点

func (*WorkerUseCase) EnableWorker

func (u *WorkerUseCase) EnableWorker(ctx kratosx.Context, id uint32) error

EnableWorker 启动指定工作节点

func (*WorkerUseCase) PageWorker

func (u *WorkerUseCase) PageWorker(ctx kratosx.Context, req *PageWorkerRequest) ([]*Worker, uint32, error)

PageWorker 获取分页工作节点

func (*WorkerUseCase) UpdateWorker

func (u *WorkerUseCase) UpdateWorker(ctx kratosx.Context, worker *Worker) error

UpdateWorker 更新指定工作节点

func (*WorkerUseCase) UpdateWorkerGroup

func (u *WorkerUseCase) UpdateWorkerGroup(ctx kratosx.Context, tg *WorkerGroup) error

UpdateWorkerGroup 删除指定节点分组

Jump to

Keyboard shortcuts

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