Step
Wrap business operations in named steps for latency, status, and failure analytics.
Step Contract
LoadStrikeStep.Run<T>(stepName, context, run) executes one logical unit and records timing/status. Step name is required and appears in step-level report tables. TypeScript/JavaScript mirrors the same contract by returning the typed reply directly rather than a wrapper object.
Return Types
Return LoadStrikeResponse.Ok(...) for success and LoadStrikeResponse.Fail(...) for failures. Success helpers use statusCode, sizeBytes, message, customLatencyMs; failure helpers use statusCode, message, sizeBytes, customLatencyMs; both also support optional typed payloads. Parameterless Ok()/Fail() preserve zero custom latency, while overload defaults use the observed step/scenario elapsed time when custom latency is omitted.
Scenario Reply
In a scenario run delegate, return Step.AsReply() so scenario status reflects step outcome. TypeScript/JavaScript payload replies expose Step.AsReply() plus reply properties such as StatusCode, Message, IsError, and Payload. Multi-step scenarios can combine step outcomes and return the final response.
Runtime Controls in Step
Use context.GetScenarioTimerTime() for elapsed-time checks, context.StopScenario(...) to stop one scenario, and context.StopCurrentTest(...) to end the whole run when critical conditions are reached.
Feature Usage Samples
How to use snippets for Step.
Switch between C#, Java, Python, TypeScript, and JavaScript to see the native SDK shape for this sample.
Licensing note: every runnable sample requires a valid runner key via WithRunnerKey("...") or config key LoadStrike:RunnerKey.
Step
var scenario = LoadStrikeScenario.Create("step-demo", async context =>
{
var step = await LoadStrikeStep.Run<string>("GET /health", context, () =>
Task.FromResult(LoadStrikeResponse.Ok("ok", statusCode: "200")));
return step.AsReply();
});
import com.loadstrike.runtime.LoadStrikeRuntime.LoadStrikeResponse;
import com.loadstrike.runtime.LoadStrikeRuntime.LoadStrikeScenario;
import com.loadstrike.runtime.LoadStrikeRuntime.LoadStrikeStep;
var scenario = LoadStrikeScenario.create(
"step-demo",
context -> LoadStrikeStep.run(
"GET /health",
context,
() -> LoadStrikeResponse.ok("200")
).asReply()
);
from loadstrike_sdk import LoadStrikeResponse, LoadStrikeScenario, LoadStrikeStep
scenario = LoadStrikeScenario.create(
"step-demo",
lambda context: LoadStrikeStep.run(
"GET /health",
context,
lambda: LoadStrikeResponse.ok("200"),
)["as_reply"](),
)
import { LoadStrikeResponse, LoadStrikeScenario, LoadStrikeStep } from "@loadstrike/loadstrike-sdk";
const scenario = LoadStrikeScenario.create("step-demo", async (context) => {
return LoadStrikeStep.run(
"GET /health",
context,
async () => LoadStrikeResponse.ok("200")
);
});
const { LoadStrikeResponse, LoadStrikeScenario, LoadStrikeStep } = require("@loadstrike/loadstrike-sdk");
const scenario = LoadStrikeScenario.create("step-demo", async (context) => {
return LoadStrikeStep.run(
"GET /health",
context,
async () => LoadStrikeResponse.ok("200")
);
});
Used APIs
Execute one named operation and capture step-specific timing, status code, and failure analytics.
Return the step outcome back to the scenario so the scenario result reflects the same success or failure state across all supported SDKs.