monitor

package
v2.2.0+incompatible Latest Latest
Warning

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

Go to latest
Published: May 15, 2022 License: Apache-2.0 Imports: 9 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrRunCompletedJob   = errors.New("error: try run completed job")
	ErrRunRunningJob     = errors.New("error: try run running job")
	ErrStopNonRunningJob = errors.New("error: imposible stop non running job")
	ErrContextCancelled  = errors.New("context cancelled")
)
View Source
var States = map[State]string{
	Stopped:   `Stopped`,
	Running:   `Running`,
	Failed:    `Failed`,
	Completed: `Completed`,
}

Functions

This section is empty.

Types

type DiscretWork

type DiscretWork interface {
	DoWork(context.Context) (bool, error)
	GetProgress() model.DownloadProgress
	BeforeRun(context.Context) error
	AfterStop() error
	IsPartialDownload() bool
	ResetProgress()
}

type MonitoredWorker

type MonitoredWorker struct {
	Itw DiscretWork
	// contains filtered or unexported fields
}

func (*MonitoredWorker) GetId

func (mw *MonitoredWorker) GetId() string

func (*MonitoredWorker) GetProgress

func (mw *MonitoredWorker) GetProgress() model.DownloadProgress

func (*MonitoredWorker) GetState

func (mw *MonitoredWorker) GetState() State

func (*MonitoredWorker) ResetProgress

func (mw *MonitoredWorker) ResetProgress()

func (*MonitoredWorker) Start

func (mw *MonitoredWorker) Start(ctx context.Context) error

func (*MonitoredWorker) Stop

func (mw *MonitoredWorker) Stop(ctx context.Context) error

type State

type State int
const (
	Stopped State = iota
	Running
	Failed
	Completed
)

func (State) Int

func (s State) Int() int

func (State) String

func (s State) String() string

type WorkerPool

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

func NewWorkerPool

func NewWorkerPool() *WorkerPool

func (*WorkerPool) AfterComplete

func (wp *WorkerPool) AfterComplete(fn func(context.Context) error)

func (*WorkerPool) AppendWork

func (wp *WorkerPool) AppendWork(iv *MonitoredWorker)

func (*WorkerPool) Completed

func (wp *WorkerPool) Completed() bool

func (*WorkerPool) GetAllProgress

func (wp *WorkerPool) GetAllProgress() []model.DownloadProgress

func (*WorkerPool) ResetAllProgress

func (wp *WorkerPool) ResetAllProgress()

func (*WorkerPool) StartAll

func (wp *WorkerPool) StartAll() []error

func (*WorkerPool) State

func (wp *WorkerPool) State() State

func (*WorkerPool) StopAll

func (wp *WorkerPool) StopAll() []error

Jump to

Keyboard shortcuts

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