scenario

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package scenario parses YAML scenario files and exposes weighted tool-call selection and argument templating for the orchestrator.

Index

Constants

View Source
const DefaultTimeout = 30 * time.Second

DefaultTimeout is the per-call timeout used when neither the tool nor the workload specifies one.

Variables

This section is empty.

Functions

func Example

func Example() string

Example returns a reference scenario document used in README and tests.

func RenderArgs

func RenderArgs(args map[string]any, ctx TemplateContext) (map[string]any, error)

RenderArgs returns a freshly-built args map with any string template placeholders rendered via text/template.

Types

type Picker

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

Picker selects tools according to their weights.

func NewPicker

func NewPicker(s *Scenario, seed int64) *Picker

NewPicker creates a weighted tool picker. seed sets the deterministic random source; pass 0 for a random seed.

func (*Picker) Next

func (p *Picker) Next() *ToolCall

Next returns a pointer to the next selected tool. Safe for a single caller goroutine; wrap with sync if sharing across goroutines.

type Scenario

type Scenario struct {
	Name      string          `yaml:"name"`
	Transport TransportConfig `yaml:"transport"`
	Workload  Workload        `yaml:"workload"`
	Tools     []ToolCall      `yaml:"tools"`
}

Scenario is the top-level parsed YAML.

func Load

func Load(path string) (*Scenario, error)

Load reads and parses a YAML scenario from disk.

func Parse

func Parse(data []byte) (*Scenario, error)

Parse parses a YAML scenario from bytes.

func ParseReader

func ParseReader(r io.Reader) (*Scenario, error)

ParseReader parses a scenario from an io.Reader.

func (*Scenario) CallTimeout

func (s *Scenario) CallTimeout(t *ToolCall) time.Duration

CallTimeout returns the effective timeout for a tool: tool override > workload timeout > DefaultTimeout.

func (*Scenario) Validate

func (s *Scenario) Validate() error

Validate checks that the scenario is internally consistent. Returns the first error encountered.

type TemplateContext

type TemplateContext struct {
	Iter int64
	Env  map[string]string
	Rand float64
}

TemplateContext is the variable environment exposed to arg templates.

type ToolCall

type ToolCall struct {
	Name    string         `yaml:"name"`
	Weight  int            `yaml:"weight"`
	Args    map[string]any `yaml:"args"`
	Timeout time.Duration  `yaml:"timeout"`
}

ToolCall is a single weighted tool invocation template.

type TransportConfig

type TransportConfig struct {
	Type    string            `yaml:"type"`
	Cmd     string            `yaml:"cmd"`
	Args    []string          `yaml:"args"`
	Env     map[string]string `yaml:"env"`
	URL     string            `yaml:"url"`
	Headers map[string]string `yaml:"headers"`
}

TransportConfig selects and configures the transport.

type Workload

type Workload struct {
	Rate        float64       `yaml:"rate"`
	Concurrency int           `yaml:"concurrency"`
	Duration    time.Duration `yaml:"duration"`
	Requests    int           `yaml:"requests"`
	Warmup      time.Duration `yaml:"warmup"`
	Cooldown    time.Duration `yaml:"cooldown"`
	ThinkTime   time.Duration `yaml:"think_time"`
	Timeout     time.Duration `yaml:"timeout"`
}

Workload configures the load profile.

Jump to

Keyboard shortcuts

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