engine

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2023 License: MPL-2.0 Imports: 13 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Pools []InstancePoolConfig `config:"pools" validate:"required,dive"`
}

type Engine

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

func New

func New(log *zap.Logger, m Metrics, conf Config) *Engine

func (*Engine) Run

func (e *Engine) Run(ctx context.Context) error

Run runs all instance pools. Run blocks until fail happen, or all pools subroutines are successfully finished. Ctx will be ancestor to Contexts passed to AmmoQueue, Gun and Aggregator. That's ctx cancel cancels shooting and it's Context values can be used for communication between plugins.

func (*Engine) Wait

func (e *Engine) Wait()

Wait blocks until all run engine tasks are finished. Useful only in case of fail, because successful run awaits all started tasks.

type InstancePoolConfig

type InstancePoolConfig struct {
	ID              string
	Provider        core.Provider                 `config:"ammo" validate:"required"`
	Aggregator      core.Aggregator               `config:"result" validate:"required"`
	NewGun          func() (core.Gun, error)      `config:"gun" validate:"required"`
	RPSPerInstance  bool                          `config:"rps-per-instance"`
	NewRPSSchedule  func() (core.Schedule, error) `config:"rps" validate:"required"`
	StartupSchedule core.Schedule                 `config:"startup" validate:"required"`
	DiscardOverflow bool                          `config:"discard_overflow"`
}

type Metrics

type Metrics struct {
	Request        *monitoring.Counter
	Response       *monitoring.Counter
	InstanceStart  *monitoring.Counter
	InstanceFinish *monitoring.Counter
}

TODO(skipor): use something github.com/rcrowley/go-metrics based. Its high level primitives like Meter can be not fast enough, but EWMAs and Counters should good for that.

Jump to

Keyboard shortcuts

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