Step

A step is a named part of a scenario. Use steps when you want reports to show where time and failures happened inside the workflow.

What this page helps you do

What this page helps you do

A step is a named part of a scenario. Use steps when you want reports to show where time and failures happened inside the workflow.

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 Step 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

Step Contract

LoadStrikeStep.Run<T>(stepName, context, run) executes one logical unit and records its timing and status. The step name is required because it appears in step-level report tables, and all supported SDKs now return the same LoadStrikeReply<TPayload>-style result for that work. Every supported SDK also exposes an explicit async-named alias for readability on the public surface: RunAsync in C# and Go, runAsync in Java, TypeScript, and JavaScript, and run_async in Python.

Return Types

Use LoadStrikeResponse.Ok(...) for success and LoadStrikeResponse.Fail(...) for failure. Those helpers let you record statusCode, sizeBytes, message, customLatencyMs, and optional typed payloads. Parameterless Ok()/Fail() keep zero custom latency, while overload defaults use the observed step or scenario elapsed time when custom latency is omitted. In the Go parity wrapper surface, the non-generic reply exposes the status accessors plus an idempotent AsReply() projection, while typed namespace replies stay closer to the .NET generic contract by exposing Payload() and AsReply() on LoadStrikeResponse.OkWith(...) / FailWith(...). The package-level Go helpers OKWith(...), FailWith(...), and RunStep(...) remain available for explicitly generic typed flows.

Scenario Reply

If you want the scenario result to reflect the same outcome as the step, return Step.AsReply(), step.asReply(), or step.as_reply() from the scenario delegate. In Go, typed reply flows still project through LoadStrikeResponse.OkWith(...) / FailWith(...).AsReply(), while the untyped LoadStrikeReply now also exposes AsReply() so shared scenario-return call sites can stay uniform across SDKs.

Runtime Controls in Step

Use context.GetScenarioTimerTime() when the step needs elapsed-time checks, context.StopScenario(...) when one scenario should stop, and context.StopCurrentTest(...) when the entire run should end because a critical condition has been reached.

SDK reference samples

Use these SDK samples to compare how Step 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.

Step

using LoadStrike;

var httpClient = new HttpClient
{
    BaseAddress = new Uri("https://api.example.com")
};

var scenario = LoadStrikeScenario.Create("submit-orders", async context =>
{
    var step = await LoadStrikeStep.Run<string>("POST /orders", context, async () =>
    {
        using var response = await httpClient.PostAsJsonAsync("/orders", new
        {
            orderId = $"ord-{context.InvocationNumber}",
            amount = 49.95m
        });

        return response.IsSuccessStatusCode
            ? LoadStrikeResponse.Ok<string>(statusCode: ((int)response.StatusCode).ToString())
            : LoadStrikeResponse.Fail<string>(statusCode: ((int)response.StatusCode).ToString());
    });

    return step.AsReply();
})
.WithLoadSimulations(LoadStrikeSimulation.Inject(10, TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(20)));

LoadStrikeRunner.RegisterScenarios(scenario)
    .WithRunnerKey("rkl_your_local_runner_key")
    .Run();

Step parameters and reply behavior

Run<T>(name, context, run)

name is the report-visible step name, context is the active scenario context, and run is the delegate that returns a LoadStrike reply.

name

Required readable step name. This exact value is what users see in step tables, threshold targeting, and sink exports.

context

Gives the step access to invocation data, scenario timers, stop helpers, random values, node info, and test metadata.

run delegate

This is where the real business operation happens, such as an HTTP call, browser action, or broker publish.

LoadStrikeResponse.Ok / Fail

Use these helpers to map the actual business outcome into a status code, optional message, optional payload, optional size, and optional custom latency.

AsReply()

Returns the step result back to the scenario so the scenario status reflects the same success or failure state.