Runner Builder

The runner builder is the fluent API for registering scenarios, applying runtime settings, and executing a LoadStrike run.

What this page helps you do

What this page helps you do

The runner builder is the fluent API for registering scenarios, applying runtime settings, and executing a LoadStrike run.

Who this is for

Engineers writing or reviewing scenario code in one of the supported SDKs.

Prerequisites

  • A scenario or runtime surface you want to wire correctly in code

By the end

The exact SDK surface you need for this part of the runtime.

Use this page when

Use this reference when you already know the workflow and need the exact Runner Builder API surface in code.

Visual guide

Sequence diagram showing how a LoadStrike workflow moves from setup to report output.
This page fits into the same setup, run, correlate, and report flow as the rest of the public LoadStrike runtime.

Guide

Builder Pattern

Use LoadStrikeRunner.Create() to start fluent composition, then AddScenario or AddScenarios and Configure(...) to apply context options before Run(). Go, Java, Python, and TypeScript or JavaScript all mutate the same runner or context instance through fluent builders and static helper wrappers. The Go SDK documents the returned-context Configure callback on the `.NET`-named wrapper surface as `Configure(func(ctx loadstrike.LoadStrikeContext) loadstrike.LoadStrikeContext)`, keeps `Create()` as the preferred public builder entry point, and also supports `NewRunner()` as a wrapper constructor that returns `LoadStrikeRunner` instead of exposing the native runtime builder structs directly. When you already have a reusable context, ConfigureContext(context) merges that context back into the builder without dropping its registered scenarios.

BuildContext

Use BuildContext() when you want one configured LoadStrikeContext that can be reused for multiple runs. C#, Go, Java, Python, TypeScript, and JavaScript all keep the registered scenario set so LoadStrikeContext.Run() and LoadStrikeRunner.Run(context) can execute directly from that reusable context. The various Configure flows, including ConfigureContext(context), add context changes without dropping the registered scenarios. In Go, the public wrapper surface returns LoadStrikeRunResult directly from Run().

Configure Merge Behavior

Chained Configure(...) calls merge into the same LoadStrikeContext. Omitted values stay intact, while later calls replace only the fields they actually set. That makes it safe to layer identity, report, cluster, sink, and plugin options in separate builder steps instead of rebuilding the context from scratch.

Builder Guardrails

The builder validates that at least one scenario is registered before BuildContext() or Run() can succeed. Empty builder state and empty target resolution both fail fast instead of silently producing a no-op run.

Run Overloads

Use Run() for normal execution and Run(string[] args) or Run(params string[] args) when launch-time overrides should be applied. Across all SDKs, Run() returns the full LoadStrikeRunResult with startedUtc, completedUtc, reportFiles, disabledSinks, sinkErrors, metrics, scenarioStats, flattened stepStats, scenarioDurationsMs, correlationRows, and failedCorrelationRows. It also fails fast when no scenarios are registered or when target selection resolves to none. Reusable LoadStrikeContext instances keep CLI-applied overrides after Run(args), while runner-level Run(args) calls remain one-shot per execution. Go supports variadic Run override flows for launch-time settings, and TypeScript or JavaScript also support array or variadic Run override flows, case-insensitive keys, malformed-token ignoring, numeric NodeType enum tokens, and execution-time `--config` or `--infraconfig` file loading. The Go parity wrapper now mirrors the `.NET` result contract more closely by exposing integer ScenarioDurationsMs values on the final wrapper and by keeping node type on NodeInfo rather than duplicating it at the top level of LoadStrikeRunResult.

Language Differences

The core model stays the same across SDKs, but a few helpers and result shapes use language-specific names. Check these notes when you switch languages or compare samples.

Run()

C#, Go, Java, Python, TypeScript, and JavaScript all expose Run() on the runner and reusable context surfaces. Run() returns the full LoadStrikeRunResult payload with reportFiles, disabledSinks, sinkErrors, metrics, flattened stepStats, scenarioDurationsMs, correlationRows, and failedCorrelationRows. Reports and sink exports are built from that same result automatically.

SDK reference samples

Use these SDK samples to compare how Runner Builder is exposed across the supported languages before you wire it into a full scenario.

If you run these examples locally, add a valid runner key before execution starts. Set it with WithRunnerKey("...") or the config key LoadStrike:RunnerKey.

Runner Builder

using LoadStrike;

var scenario = LoadStrikeScenario.Empty("submit-orders")
    .WithLoadSimulations(LoadStrikeSimulation.KeepConstant(1, TimeSpan.FromSeconds(20)));

var runner = LoadStrikeRunner.Create()
    .AddScenario(scenario)
    .Configure(ctx => ctx.WithReportFolder("./reports").WithRunnerKey("rkl_your_local_runner_key"));

var context = runner.BuildContext();
var stats = context.Run("--testsuite=orders-smoke --testname=submit-orders");

Runner builder methods

Create()

Starts an empty fluent builder.

AddScenario(scenario) / AddScenarios(scenarios)

Adds one or more scenarios to the builder. At least one scenario must exist before BuildContext or Run can succeed.

Configure(ctx => ...)

Applies any LoadStrikeContext configuration such as runner key, report output, cluster settings, sinks, or plugins.

Configure merge behavior

Chained Configure calls merge into the same context. Later calls replace only the fields they set, while omitted settings stay intact.

WithTestSuite / WithTestName / WithSessionId

Shortcut builder methods for the most common run identity fields.

WithReportFolder / WithReportingInterval / WithoutReports

Shortcut builder methods for common report-output behavior.

WithClusterCommandTimeout / WithRestartIterationMaxAttempts

Shortcut builder methods for two frequently adjusted runtime controls.

BuildContext()

Materializes a reusable LoadStrikeContext after validating that at least one scenario was added. Empty builder state and empty target resolution both fail fast.

Run() / Run(args)

Builds the context and executes it immediately. Run(args) applies one-shot CLI-style overrides.

The builder behaves the same across C#, Go, Java, Python, TypeScript, and JavaScript. It keeps registered scenarios in the reusable context, fails fast when the selected scenario set is empty, preserves omitted settings during partial configure merges, and always returns the full LoadStrikeRunResult from Run().