worker

package
v2.54.0 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2026 License: MIT Imports: 24 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BatchOptions

type BatchOptions struct {
	StartIndex        int
	NumJobs           int
	TotalWorkers      int
	Delay             time.Duration
	DelayBefore       time.Duration
	AbortOnErrorCount int
	SemanticMethod    string

	PostActions []flags.Action

	InputData []string

	// Generic values
	ConfirmationMessage func(string, any, any) (string, error)
	// contains filtered or unexported fields
}

func (*BatchOptions) GetConfirmationMessage added in v2.41.0

func (b *BatchOptions) GetConfirmationMessage(operation string, value any, input any) (string, error)

func (*BatchOptions) GetItem

func (b *BatchOptions) GetItem() (string, error)

type GenericWorker added in v2.41.0

type GenericWorker struct {
	Config         *config.Config
	IO             *iostreams.IOStreams
	Logger         *logger.Logger
	Client         *c8y.Client
	ActivityLogger *activitylogger.ActivityLogger
	CheckError     func(error) error
	Execute        Runner
}

func NewGenericWorker added in v2.41.0

func NewGenericWorker(log *logger.Logger, cfg *config.Config, iostream *iostreams.IOStreams, client *c8y.Client, activityLog *activitylogger.ActivityLogger, runFunc Runner, checkError func(error) error) (*GenericWorker, error)

func (*GenericWorker) GetBatchOptions added in v2.41.0

func (w *GenericWorker) GetBatchOptions(cmd *cobra.Command) (*BatchOptions, error)

func (*GenericWorker) GetMaxJobs added in v2.41.0

func (w *GenericWorker) GetMaxJobs() int64

GetMaxJob maximum number of jobs allowed

func (*GenericWorker) GetMaxWorkers added in v2.41.0

func (w *GenericWorker) GetMaxWorkers() int

GetMaxWorkers maximum number of workers

func (*GenericWorker) Run added in v2.41.0

func (w *GenericWorker) Run(cmd *cobra.Command, iter iterator.Iterator, inputIterators *flags.RequestInputIterators) error

func (*GenericWorker) RunSequentially added in v2.41.0

func (w *GenericWorker) RunSequentially(cmd *cobra.Command, iter iterator.Iterator, inputIterators *flags.RequestInputIterators) error

func (*GenericWorker) StartWorker added in v2.41.0

func (w *GenericWorker) StartWorker(id int, jobs <-chan Job, results chan<- error, prog *progressbar.ProgressBar, wg *sync.WaitGroup)

These workers will receive work on the `jobs` channel and send the corresponding results on `results`

type Job added in v2.41.0

type Job struct {
	ID            int64
	Value         any
	CommonOptions config.CommonCommandOptions
	Input         any
	Options       BatchOptions
}

type RequestHandler

type RequestHandler func(requests []c8y.RequestOptions, input any, commonOptions config.CommonCommandOptions) (*c8y.Response, error)

type Runner added in v2.41.0

type Runner func(Job) (any, error)

type Worker

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

func NewWorker

func NewWorker(log *logger.Logger, cfg *config.Config, iostream *iostreams.IOStreams, client *c8y.Client, activityLog *activitylogger.ActivityLogger, reqHandlerFunc RequestHandler, checkError func(error) error) (*Worker, error)

func (*Worker) GetMaxJobs

func (w *Worker) GetMaxJobs() int64

GetMaxJob maximum number of jobs allowed

func (*Worker) GetMaxWorkers

func (w *Worker) GetMaxWorkers() int

GetMaxWorkers maximum number of workers

func (*Worker) ProcessRequestAndResponse

func (w *Worker) ProcessRequestAndResponse(cmd *cobra.Command, r *c8y.RequestOptions, inputIterators *flags.RequestInputIterators) error

Jump to

Keyboard shortcuts

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