pool

package
v0.13.1 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2025 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MoonshotPool

type MoonshotPool struct {
	Tasks []*MoonshotTask
	// contains filtered or unexported fields
}

MoonshotPool is a worker group that runs a number of tasks at a configured concurrency.

func NewMoonshotPool

func NewMoonshotPool(tasks []*MoonshotTask, concurrency int) *MoonshotPool

NewMoonshotPool initializes a new pool with the given tasks and at the given concurrency.

func (*MoonshotPool) Run

func (p *MoonshotPool) Run()

Run runs all work within the pool and blocks until it's finished.

type MoonshotTask

type MoonshotTask struct {
	// Err holds an error that occurred during a task. Its
	// result is only meaningful after Run has been called
	// for the pool that holds it.
	Err error

	Body       []byte
	MetricType string
	Device     string
	// contains filtered or unexported fields
}

MoonshotTask encapsulates a work item that should go in a moonshot work pool.

func NewMoonshotTask

func NewMoonshotTask(f func() ([]byte, string, string, error)) *MoonshotTask

NewMoonshotTask initializes a new task based on a given HPE moonshot work function.

func (*MoonshotTask) Run

func (t *MoonshotTask) Run(wg *sync.WaitGroup)

Run runs a Task and does appropriate accounting via a given sync.WorkGroup.

type Pool

type Pool struct {
	Tasks []*Task
	// contains filtered or unexported fields
}

Pool is a worker group that runs a number of tasks at a configured concurrency.

func NewPool

func NewPool(tasks []*Task, concurrency int) *Pool

NewPool initializes a new pool with the given tasks and at the given concurrency.

func (*Pool) AddTask

func (p *Pool) AddTask(task *Task)

func (*Pool) Run

func (p *Pool) Run()

Run runs all work within the pool and blocks until it's finished.

type Task

type Task struct {
	// Err holds an error that occurred during a task. Its
	// result is only meaningful after Run has been called
	// for the pool that holds it.
	Err error

	Body           []byte
	MetricHandlers []common.Handler
	URL            string
	// contains filtered or unexported fields
}

Task encapsulates a work item that should go in a work pool

func NewTask

func NewTask(f func() ([]byte, error), url string, handlers []common.Handler) *Task

NewTask initializes a new task based on a given work function.

func (*Task) Run

func (t *Task) Run(wg *sync.WaitGroup)

Run runs a Task and does appropriate accounting via a given sync.WorkGroup.

Jump to

Keyboard shortcuts

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