schedule

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ActionOwner = "owner"
	ActionAdmin = "admin"
	ActionUser  = "user"

	AuthDomain = "schedule"
)
View Source
const (
	TaskStatusRunning = "running"
	TaskStatusError   = "error"
	TaskStatusSuccess = "success"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Controller

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

func NewController

func NewController() *Controller

func (*Controller) RegisterRoute

func (c *Controller) RegisterRoute(group *gin.RouterGroup)

type Executor

type Executor struct {
	Name        string `json:"name"`
	DisplayName string `json:"displayName"`
	// contains filtered or unexported fields
}

type Manager

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

func GetExecutorManager

func GetExecutorManager() *Manager

func (*Manager) GetExecutor

func (m *Manager) GetExecutor(name string) (func() Task, error)

func (*Manager) GetExecutors

func (m *Manager) GetExecutors() []Executor

func (*Manager) Register

func (m *Manager) Register(executor Executor, task func() Task) error

type Record

type Record struct {
	ID         uuid.UUID `json:"id" gorm:"primary_key;type:uuid;" swaggerignore:"true"`
	ScheduleID uuid.UUID `json:"scheduleID" gorm:"type:uuid;"`
	Title      string    `json:"title" validate:"required"`
	Executor   string    `json:"executor" validate:"required"`
	Params     string    `json:"params"`
	Status     string    `json:"status"`

	database.BaseModel
}

func (*Record) BeforeCreate

func (r *Record) BeforeCreate(tx *gorm.DB) error

func (*Record) TableName

func (r *Record) TableName() string

type Schedule

type Schedule struct {
	ID         uuid.UUID `json:"id" gorm:"primary_key;type:uuid;" example:"00000000-0000-0000-0000-000000000000"`
	Title      string    `json:"title" validate:"required"`
	Desc       string    `json:"desc"`
	CronString string    `json:"cronString" validate:"required" example:"*/5 * * * * *"`
	Executor   string    `json:"executor" validate:"required" example:"test"`
	NextTime   time.Time `json:"nextTime" gorm:"-" swaggerignore:"true"`
	Params     string    `json:"params"`
	Enabled    bool      `json:"enabled" example:"true"`
	Status     string    `json:"status"`

	database.BaseModel
}

func (*Schedule) BeforeCreate

func (s *Schedule) BeforeCreate(tx *gorm.DB) error

func (*Schedule) TableName

func (s *Schedule) TableName() string

type Service

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

func GetService

func GetService() *Service

func (*Service) AddSchedule

func (s *Service) AddSchedule(schedule *Schedule) error

AddSchedule add schedule

func (*Service) BatchDeleteSchedule

func (s *Service) BatchDeleteSchedule(ids []uuid.UUID) error

BatchDeleteSchedule batch delete schedule

func (*Service) BatchSetScheduleEnable

func (s *Service) BatchSetScheduleEnable(ids []uuid.UUID, enabled bool) error

BatchSetScheduleEnable batch set schedule enable

func (*Service) DeleteSchedule

func (s *Service) DeleteSchedule(id uuid.UUID) error

DeleteSchedule delete schedule

func (*Service) DetailSchedule

func (s *Service) DetailSchedule(id uuid.UUID) (*Schedule, error)

DetailSchedule detail schedule

func (*Service) GetTaskExecutors

func (s *Service) GetTaskExecutors() []Executor

GetTaskExecutors get task executors

func (*Service) Initialize

func (s *Service) Initialize() (err error)

func (*Service) PageSchedule

func (s *Service) PageSchedule(num, size int, schedule *Schedule) (*database.Pager[*Schedule], error)

PageSchedule page schedules

func (*Service) PageScheduleRecord

func (s *Service) PageScheduleRecord(num, size int, record *Record) (*database.Pager[*Record], error)

PageScheduleRecord page task records

func (*Service) UpdateSchedule

func (s *Service) UpdateSchedule(schedule *Schedule) error

UpdateSchedule update schedule

type Task

type Task interface {
	// Run task entry
	Run()
	// SetParams set task params, you can use it to set task configuration
	SetParams(params string)
}

type TestTask

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

func (*TestTask) Run

func (t *TestTask) Run()

func (*TestTask) SetParams

func (t *TestTask) SetParams(params string)

type WrappedTask

type WrappedTask struct {
	Task
	// contains filtered or unexported fields
}

func NewWrapper

func NewWrapper(task Task, schedule *Schedule) *WrappedTask

func (*WrappedTask) Run

func (w *WrappedTask) Run()

Jump to

Keyboard shortcuts

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