worker

package
v0.12.9 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2023 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewExecutorInvokeWorker

func NewExecutorInvokeWorker(exector executor, status Status,
	cfg config.RepoConfig,
	signal chan int) (*executorInvokeWorker, error)

creates a new executorInvokeWorker, which encapsules an executor into a Worker and provides functinalities like auto-retry and state management

Types

type ExternalWorker

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

ExternalWorker is a stub worker which always returns {Idle: false, Result: true}.

func NewExternalWorker

func NewExternalWorker(cfg config.RepoConfig) (*ExternalWorker, error)

func (*ExternalWorker) GetConfig

func (ew *ExternalWorker) GetConfig() config.RepoConfig

func (*ExternalWorker) GetStatus

func (ew *ExternalWorker) GetStatus() Status

func (*ExternalWorker) RunSync

func (ew *ExternalWorker) RunSync()

func (*ExternalWorker) TriggerSync

func (ew *ExternalWorker) TriggerSync()

type Status

type Status struct {
	// Result is true if sync succeed, else false
	Result bool
	// LastFinished indicates last success time
	LastFinished time.Time
	// Idle stands for whether worker is idle, false if syncing
	Idle bool
	// Last stdout(s) for admin. Internal implementation may vary to provide it in Status()
	Stdout []string
	// Last stderr(s) for admin. Internal implementation may vary to provide it in Status()
	Stderr []string
}

Status shows sync result and last timestamp.

type Worker

type Worker interface {
	// This call should be thread-safe
	GetStatus() Status
	// This should block forever
	RunSync()
	// This call should be thread-safe
	TriggerSync()

	GetConfig() config.RepoConfig
}

Worker declares interface for workers using diffenent ways of sync.

func NewWorker

func NewWorker(cfg config.RepoConfig, lastFinished time.Time) (Worker, error)

NewWorker generates a worker by config and log.

Jump to

Keyboard shortcuts

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