Class BowireMockHostManager

Namespace
Kuestenlogik.Bowire.Mock.Management
Assembly
Kuestenlogik.Bowire.Mock.dll

Single owner of every UI-spun mock server. Replaces the v1.x MockRegistry / v2.x BowireMockHostManager split — there's now exactly one registry behind /api/mocks* (#223).

public sealed class BowireMockHostManager : IAsyncDisposable
Inheritance
BowireMockHostManager
Implements
Inherited Members

Remarks

Lifecycle: singleton via AddBowireMockManagement(); disposed on host shutdown. Every StartAsync(string, string, string, int, CancellationToken) writes the recording JSON to a temp file (the underlying MockServer ingests via path), opens the host on a free local port, and tracks the entry in a ConcurrentDictionary<TKey, TValue>. StopAsync(string, CancellationToken) tears the server down + deletes the temp file.

Concurrency: List / Start / Stop / Get can interleave freely. The temp-file write is awaited before StartAsync(MockServerOptions, CancellationToken), so a successful start always has the file on disk.

Constructors

BowireMockHostManager()

public BowireMockHostManager()

Methods

AddStub(string, BowireRecordingStep)

Add a stub to a running mock. Null when the mock isn't running.

public BowireRecordingStep? AddStub(string mockId, BowireRecordingStep stub)

Parameters

mockId string
stub BowireRecordingStep

Returns

BowireRecordingStep

DisposeAsync()

public ValueTask DisposeAsync()

Returns

ValueTask

Get(string)

Look up a single mock by id. Returns null if not running.

public MockHostHandle? Get(string mockId)

Parameters

mockId string

Returns

MockHostHandle

GetFaults(string)

Live fault-injection rules of a running mock (#170). Null when the mock id isn't in the registry.

public FaultRuleSet? GetFaults(string mockId)

Parameters

mockId string

Returns

FaultRuleSet

GetRequestLog(string)

Access the request log for a running mock (#57 — Mocks panel request tail). Returns null when the mock id isn't in the registry.

public MockRequestLog? GetRequestLog(string mockId)

Parameters

mockId string

Returns

MockRequestLog

GetScenarioStates(string)

Current state of every scenario in a running mock (name → state). Null when not running.

public IReadOnlyDictionary<string, string>? GetScenarioStates(string mockId)

Parameters

mockId string

Returns

IReadOnlyDictionary<string, string>

GetStub(string, string)

Get a single stub by id.

public BowireRecordingStep? GetStub(string mockId, string stubId)

Parameters

mockId string
stubId string

Returns

BowireRecordingStep

GetStubs(string)

List the stubs (recording steps) of a running mock.

public IReadOnlyList<BowireRecordingStep>? GetStubs(string mockId)

Parameters

mockId string

Returns

IReadOnlyList<BowireRecordingStep>

List()

Snapshot of every running mock. Order undefined; UI sorts by StartedAtUtc.

public IReadOnlyCollection<MockHostHandle> List()

Returns

IReadOnlyCollection<MockHostHandle>

RemoveStub(string, string)

Remove a stub by id. False when the mock or stub isn't found.

public bool RemoveStub(string mockId, string stubId)

Parameters

mockId string
stubId string

Returns

bool

ResetScenarios(string)

Reset all scenarios to Started. False when not running.

public bool ResetScenarios(string mockId)

Parameters

mockId string

Returns

bool

ResetStubs(string)

Restore a running mock's stubs to its baseline recording. False when not running.

public bool ResetStubs(string mockId)

Parameters

mockId string

Returns

bool

SetScenarioState(string, string, string)

Force a scenario to a state. False when the mock isn't running or the scenario is unknown.

public bool SetScenarioState(string mockId, string name, string state)

Parameters

mockId string
name string
state string

Returns

bool

StartAsync(string, string, string, int, CancellationToken)

Boot a mock host for the supplied recording JSON.

public Task<MockHostHandle> StartAsync(string recordingJson, string recordingId, string label, int port, CancellationToken ct)

Parameters

recordingJson string

Single recording document (NOT the {"recordings":[...]} envelope).

recordingId string

Stable id of the source recording (so the workbench can correlate the running mock back to the recording that produced it). Empty when the start came from an embedded host that passed a recording payload directly.

label string

Display label (recording name or operator- supplied alias).

port int

Requested port. 0 = use the rolling allocator; any positive value pins the mock to that port (and fails the call if the port is busy).

ct CancellationToken

Cancellation.

Returns

Task<MockHostHandle>

StopAsync(string, CancellationToken)

public Task<bool> StopAsync(string mockId, CancellationToken ct)

Parameters

mockId string
ct CancellationToken

Returns

Task<bool>

TrySetFaults(string, FaultRuleSet)

Swap the fault rules of a RUNNING mock (#170 — the UI editor's apply path). Atomic reference swap; false when the mock id isn't in the registry.

public bool TrySetFaults(string mockId, FaultRuleSet faults)

Parameters

mockId string
faults FaultRuleSet

Returns

bool

UpdateStub(string, string, BowireRecordingStep)

Replace a stub by id. False when the mock or stub isn't found.

public bool UpdateStub(string mockId, string stubId, BowireRecordingStep stub)

Parameters

mockId string
stubId string
stub BowireRecordingStep

Returns

bool