dispatcher

package
v0.0.0-...-11dbc25 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CreateInstance

type CreateInstance[T Instance] func(int) (T, error)

type Info

type Info struct {
	State      InstanceState
	Status     string
	LastUpdate time.Time
	Reserved   bool

	// The optional callbacks.
	MachineInfo    func() []byte
	DetailedStatus func() []byte
}

type Instance

type Instance interface {
	io.Closer
}

type InstanceState

type InstanceState int
const (
	StateOffline InstanceState = iota
	StateBooting
	StateWaiting
	StateRunning
)

type Pool

type Pool[T Instance] struct {
	BootErrors chan error
	BootTime   stat.AverageValue[time.Duration]
	// contains filtered or unexported fields
}

Pool[T] provides the functionality of a generic pool of instances. The instance is assumed to boot, be controlled by one Runner and then be re-created. The pool is assumed to have one default Runner (e.g. to be used for fuzzing), while a dynamically controlled sub-pool might be reserved for the arbitrary Runners.

func NewPool

func NewPool[T Instance](count int, creator CreateInstance[T], def Runner[T]) *Pool[T]

func (*Pool[T]) Loop

func (p *Pool[T]) Loop(ctx context.Context)

func (*Pool[T]) ReserveForRun

func (p *Pool[T]) ReserveForRun(count int)

ReserveForRun specifies the size of the sub-pool for the execution of custom runners. The reserved instances will be booted, but the pool will not start the default runner. To unreserve all instances, execute ReserveForRun(0).

func (*Pool[T]) Run

func (p *Pool[T]) Run(job Runner[T])

Run blocks until it has found an instance to execute job and until job has finished.

func (*Pool[T]) SetDefault

func (p *Pool[T]) SetDefault(def Runner[T])

UpdateDefault forces all VMs to restart.

func (*Pool[T]) State

func (p *Pool[T]) State() []Info

func (*Pool[T]) TogglePause

func (p *Pool[T]) TogglePause(paused bool)

func (*Pool[T]) Total

func (p *Pool[T]) Total() int

type Runner

type Runner[T Instance] func(ctx context.Context, inst T, updInfo UpdateInfo)

type UpdateInfo

type UpdateInfo func(cb func(info *Info))

Jump to

Keyboard shortcuts

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