Documentation
¶
Index ¶
- Constants
- func Apportion(total uint64, weights []uint64) []uint64
- func MergeScenarioConfiguration(scenario *scenario.Descriptor, provided *yaml.Node) (string, error)
- func NodeToMap(n *yaml.Node) map[string]interface{}
- func ParseConfigNode(s string) (*yaml.Node, error)
- func ResolveMemberConfig(descriptor *scenario.Descriptor, memberConfig string, ...) (string, error)
- func ScenarioSupportsSharedCount(descriptor *scenario.Descriptor) bool
- func ScenarioSupportsSharedThroughput(descriptor *scenario.Descriptor) bool
- type ConfigImportItem
- type GroupConfig
- type MemberConfig
- type ResolvedRunConfig
- type SpammerConfig
Constants ¶
const ( // GroupModeIndependent applies only the shared overlay; each member keeps its // own throughput/count. GroupModeIndependent = "independent" // members by weight. GroupModeShared = "shared" )
Throughput modes for a spammer group.
Variables ¶
This section is empty.
Functions ¶
func Apportion ¶ added in v1.2.2
Apportion distributes total across the given weights using the largest-remainder (Hamilton) method so the integer shares sum exactly to total. A weight of 0 yields a 0 share. If all weights are 0, total is split as evenly as possible. A 0 share for an enabled member is harmless for throughput because ResolveMemberConfig bumps an injected 0 to 1 (never "unlimited").
func MergeScenarioConfiguration ¶
MergeScenarioConfiguration merges scenario defaults with the provided configuration. The provided config's key ordering and comments are preserved (the provided keys come first, in their original order, with their comments); any scenario/wallet default keys the provided config omits are appended afterwards. A nil provided config yields the defaults verbatim.
func NodeToMap ¶ added in v1.2.2
NodeToMap decodes a config node into a plain map (for callers that only need the values, e.g. group overlays applied at runtime).
func ParseConfigNode ¶ added in v1.2.2
ParseConfigNode parses a YAML config string into a mapping node, preserving comments and key order. Returns nil for empty/blank input.
func ResolveMemberConfig ¶ added in v1.2.2
func ResolveMemberConfig( descriptor *scenario.Descriptor, memberConfig string, groupOverlay map[string]any, sharedThroughput *uint64, sharedCount *uint64, sharedMaxPending *uint64, ) (string, error)
ResolveMemberConfig computes the effective YAML config for a group member. It never mutates the stored config and applies, in order:
- the group overlay (group wins) for fields the member's scenario accepts,
- a shared throughput value (gated, never 0) when sharedThroughput is set,
- a shared total_count value (gated) when sharedCount is set,
- a max_pending value: the explicit sharedMaxPending when set (gated, never 0), otherwise derived as maxPendingThroughputMultiplier * the effective throughput,
- a derived max_wallets from the effective throughput (preferred) or total_count.
Fields the member's scenario does not define are silently skipped, so the result is always valid against the scenario's config validator.
func ScenarioSupportsSharedCount ¶ added in v1.2.2
func ScenarioSupportsSharedCount(descriptor *scenario.Descriptor) bool
ScenarioSupportsSharedCount reports whether the scenario accepts a total_count field and can therefore participate in a shared-count group.
func ScenarioSupportsSharedThroughput ¶ added in v1.2.2
func ScenarioSupportsSharedThroughput(descriptor *scenario.Descriptor) bool
ScenarioSupportsSharedThroughput reports whether the scenario accepts a throughput field and can therefore participate in a shared-throughput group.
Types ¶
type ConfigImportItem ¶
type ConfigImportItem struct {
// Spammer configuration fields
Scenario string `yaml:"scenario,omitempty"`
Name string `yaml:"name,omitempty"`
Description string `yaml:"description,omitempty"`
Config yaml.Node `yaml:"config,omitempty"`
Start *bool `yaml:"start,omitempty"`
// Group fields
Group string `yaml:"group,omitempty"`
GroupConfig map[string]interface{} `yaml:"group_config,omitempty"`
// Include directive
Include string `yaml:"include,omitempty"`
}
ConfigImportItem represents either a spammer config or an include directive
type GroupConfig ¶ added in v1.2.2
type GroupConfig struct {
ThroughputMode string `json:"throughput_mode"`
TotalThroughput uint64 `json:"total_throughput"`
TotalCount uint64 `json:"total_count"`
// TotalMaxPending, when > 0, is a group-wide concurrent-pending budget split across
// enabled members by weight. When 0, each member's max_pending defaults to
// maxPendingThroughputMultiplier * its resolved throughput.
TotalMaxPending uint64 `json:"total_max_pending"`
}
GroupConfig holds the JSON metadata stored in a group row's group_config column.
func GroupConfigFromMap ¶ added in v1.2.2
func GroupConfigFromMap(m map[string]any) *GroupConfig
GroupConfigFromMap builds a GroupConfig from a decoded YAML map (export/import path).
func ParseGroupConfig ¶ added in v1.2.2
func ParseGroupConfig(s string) (*GroupConfig, error)
ParseGroupConfig parses a group row's group_config JSON, applying defaults. An empty string yields a default GroupConfig in independent mode.
func (*GroupConfig) Marshal ¶ added in v1.2.2
func (c *GroupConfig) Marshal() (string, error)
Marshal serializes the group config to its JSON storage representation.
type MemberConfig ¶ added in v1.2.2
type MemberConfig struct {
Weight uint64 `json:"weight"`
Enabled bool `json:"enabled"`
SortOrder int `json:"sort_order"`
}
MemberConfig holds the JSON metadata stored in a member row's group_config column.
func MemberConfigFromMap ¶ added in v1.2.2
func MemberConfigFromMap(m map[string]any) *MemberConfig
MemberConfigFromMap builds a MemberConfig from a decoded YAML map (export/import path).
func ParseMemberConfig ¶ added in v1.2.2
func ParseMemberConfig(s string) (*MemberConfig, error)
ParseMemberConfig parses a member row's group_config JSON, applying defaults. An empty string yields a default MemberConfig (weight 1, enabled).
func (*MemberConfig) Marshal ¶ added in v1.2.2
func (c *MemberConfig) Marshal() (string, error)
Marshal serializes the member config to its JSON storage representation.
type ResolvedRunConfig ¶ added in v1.2.2
type ResolvedRunConfig struct {
Config SpammerConfig
ConfigYAML string
}
ResolvedRunConfig pairs a runnable spammer config with its fully-resolved YAML. The Config field carries the original (sparse) import config for naming/metadata, while ConfigYAML is the complete config string to hand to the scenario, with the group overlay, shared throughput/count split and derived max_wallets already applied for group members.
func ResolveRunConfigs ¶ added in v1.2.2
func ResolveRunConfigs(all []SpammerConfig, lookup func(string) *scenario.Descriptor) ([]ResolvedRunConfig, error)
ResolveRunConfigs expands a flat list of import configs into runnable configs for the CLI single-run path, giving group members the same effective config they would receive in the daemon. Group entries (scenario == "group") are removed from the result; every remaining entry gets its config merged with scenario defaults, and members additionally get the group overlay and (in shared mode) the weight-based throughput/count split applied. The lookup callback resolves a scenario name to its descriptor; it must handle every non-group scenario referenced.
type SpammerConfig ¶
type SpammerConfig struct {
Scenario string `yaml:"scenario"`
Name string `yaml:"name"`
Description string `yaml:"description"`
Config yaml.Node `yaml:"config,omitempty"`
Start *bool `yaml:"start,omitempty"`
// Group fields
Group string `yaml:"group,omitempty"` // member: parent group name
GroupConfig map[string]interface{} `yaml:"group_config,omitempty"` // role-dependent group metadata
}
SpammerConfig represents a spammer configuration for export/import. This uses the same format as StartupSpammerConfig to maintain compatibility.
Spammer groups reuse this structure: a group entry has Scenario == "group", its Config holds the sparse overlay and GroupConfig holds {throughput_mode, total_throughput, total_count}. A member entry sets Group to the parent group's name and GroupConfig to {weight, enabled, sort_order}. Config is a yaml.Node (not a map) so the scenario config's key ordering and comments survive export/import round-trips instead of being flattened and sorted. It is a value (not a pointer) because yaml.v3 only captures a sub-document with its comments into a value Node field, not a pointer field.
func ResolveConfigImports ¶
func ResolveConfigImports(input string, baseURL string, visited map[string]bool) ([]SpammerConfig, error)
ResolveConfigImports recursively resolves includes and returns the final spammer configs