engine

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AdaptiveConfig added in v0.5.0

type AdaptiveConfig struct {
	// MaxErrorRate is the error rate [0,1] above which RPS is reduced.
	// Zero disables error-rate-based tuning.
	MaxErrorRate float64
	// MaxP99 is the P99 latency threshold above which RPS is reduced.
	// Zero disables P99-based tuning.
	MaxP99 time.Duration
	// StepDown is the multiplier applied when a threshold is breached (e.g.
	// 0.9 reduces RPS by 10%). Must be in (0,1); defaults to 0.9.
	StepDown float64
	// StepUp is the multiplier applied when all thresholds are met (e.g.
	// 1.05 increases RPS by 5%). Must be > 1; defaults to 1.05.
	StepUp float64
	// MinRPS is the floor for the auto-tuned rate. Defaults to 1.
	MinRPS int
	// MaxRPS is the ceiling for the auto-tuned rate. 0 means uncapped.
	MaxRPS int
}

AdaptiveConfig enables real-time RPS auto-tuning for PhaseTypeConstant phases. On each reporting interval the engine measures observed error rate and P99 latency and adjusts the arrival rate up or down accordingly. Requires engine.Options.ReportInterval > 0 to take effect.

func (AdaptiveConfig) IsZero added in v0.5.0

func (a AdaptiveConfig) IsZero() bool

IsZero reports whether the config contains no adaptive tuning triggers.

type Engine

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

Engine executes a test definition.

func New

func New(phases []scheduler.Phase, scenario func(context.Context) (int, error), maxConcurrency int) *Engine

New creates an engine for the given execution inputs. It retains the legacy blocking behavior. Use NewWithSaturationPolicy for an explicit policy.

func NewWithOptions added in v0.4.0

func NewWithOptions(phases []scheduler.Phase, scenario func(context.Context) (int, error), options Options) *Engine

NewWithOptions creates an engine with explicit execution settings.

func NewWithSaturationPolicy added in v0.4.0

func NewWithSaturationPolicy(
	phases []scheduler.Phase,
	scenario func(context.Context) (int, error),
	maxConcurrency int,
	saturation SaturationPolicy,
) *Engine

NewWithSaturationPolicy creates an engine with an explicit saturation policy.

func (*Engine) Run

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

Run executes each phase in sequence through the scheduler. Scenario errors are recorded in metrics and do not stop the run. A non-nil error indicates scheduler failure or context cancellation.

type Options added in v0.4.0

type Options struct {
	MaxConcurrency int
	Saturation     SaturationPolicy
	ReportInterval time.Duration
	// OnLiveSnapshot, when non-nil, is called at the end of each reporting
	// interval with the metrics observed during that window. It is invoked
	// from a background goroutine and must not block. Only active when
	// ReportInterval > 0.
	OnLiveSnapshot func(metrics.Snapshot)
	// Adaptive, when non-zero, enables real-time RPS auto-tuning for
	// PhaseTypeConstant phases. Requires ReportInterval > 0.
	Adaptive AdaptiveConfig
}

Options contains execution settings for Engine.

type SaturationPolicy added in v0.4.0

type SaturationPolicy string

SaturationPolicy controls what happens when all execution slots are in use.

const (
	// SaturationPolicyDrop preserves the configured arrival rate by discarding
	// arrivals that cannot start immediately.
	SaturationPolicyDrop SaturationPolicy = "drop"
	// SaturationPolicyBlock waits for capacity, applying backpressure to the
	// scheduler. This preserves the behavior of earlier Pulse versions.
	SaturationPolicyBlock SaturationPolicy = "block"
)

Jump to

Keyboard shortcuts

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