executor

package
v0.1.21 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2024 License: BSD-2-Clause Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const SpeedLen = 30

Variables

View Source
var (
	ModelJob = &Job{}

	ErrJobNotFound = fmt.Errorf("get job: job not found")
)

Functions

This section is empty.

Types

type Executor

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

func New

func New(
	db *gorm.DB, lib *library.Library,
	devices []string, paths Paths, scripts Scripts,
) *Executor

func (*Executor) AutoMigrate

func (e *Executor) AutoMigrate() error

func (*Executor) CreateJob

func (e *Executor) CreateJob(ctx context.Context, job *Job, param *entity.JobParam) (*Job, error)

func (*Executor) DeleteJobs

func (e *Executor) DeleteJobs(ctx context.Context, ids ...int64) error

func (*Executor) Dispatch added in v0.1.14

func (e *Executor) Dispatch(ctx context.Context, jobID int64, param *entity.JobDispatchParam) error

func (*Executor) Display

func (e *Executor) Display(ctx context.Context, job *Job) (*entity.JobDisplay, error)

func (*Executor) GetJob

func (e *Executor) GetJob(ctx context.Context, id int64) (*Job, error)

func (*Executor) GetJobExecutor added in v0.1.14

func (e *Executor) GetJobExecutor(ctx context.Context, id int64) (JobExecutor, error)

func (*Executor) ListAvailableDevices

func (e *Executor) ListAvailableDevices() []string

func (*Executor) ListJob

func (e *Executor) ListJob(ctx context.Context, filter *entity.JobFilter) ([]*Job, error)

func (*Executor) ListRecentlyUpdateJob added in v0.1.12

func (e *Executor) ListRecentlyUpdateJob(ctx context.Context, filter *entity.JobRecentlyUpdateFilter) ([]*Job, error)

func (*Executor) MGetJob

func (e *Executor) MGetJob(ctx context.Context, ids ...int64) (map[int64]*Job, error)

func (*Executor) NewLogReader

func (e *Executor) NewLogReader(jobID int64) (*os.File, error)

func (*Executor) OccupyDevice added in v0.1.14

func (e *Executor) OccupyDevice(dev string) bool

func (*Executor) ReleaseDevice added in v0.1.14

func (e *Executor) ReleaseDevice(dev string)

func (*Executor) RemoveJobExecutor added in v0.1.14

func (e *Executor) RemoveJobExecutor(ctx context.Context, id int64)

func (*Executor) SaveJob

func (e *Executor) SaveJob(ctx context.Context, job *Job) (*Job, error)

type Job

type Job struct {
	ID       int64 `gorm:"primaryKey;autoIncrement"`
	Status   entity.JobStatus
	Priority int64
	State    *entity.JobState

	CreateTime time.Time
	UpdateTime time.Time `gorm:"index:idx_update_time"`
}

func (*Job) BeforeUpdate

func (j *Job) BeforeUpdate(tx *gorm.DB) error

type JobExecutor added in v0.1.14

type JobExecutor interface {
	Initialize(ctx context.Context, param *entity.JobParam) error
	Dispatch(ctx context.Context, param *entity.JobDispatchParam) error
	Display(ctx context.Context) (*entity.JobDisplay, error)
	Close(ctx context.Context) error

	Logger() *logrus.Logger
}

type JobType added in v0.1.14

type JobType interface {
	GetExecutor(ctx context.Context, exe *Executor, job *Job) (JobExecutor, error)
}

type Paths

type Paths struct {
	Work   string `yaml:"work"`
	Source string `yaml:"source"`
	Target string `yaml:"target"`
}

type Scripts

type Scripts struct {
	Encrypt  string `yaml:"encrypt"`
	Mkfs     string `yaml:"mkfs"`
	Mount    string `yaml:"mount"`
	Umount   string `yaml:"umount"`
	ReadInfo string `yaml:"read_info"`
}

Jump to

Keyboard shortcuts

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