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
mockIdstringstubBowireRecordingStep
Returns
DisposeAsync()
public ValueTask DisposeAsync()
Returns
Get(string)
Look up a single mock by id. Returns null if not running.
public MockHostHandle? Get(string mockId)
Parameters
mockIdstring
Returns
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
mockIdstring
Returns
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
mockIdstring
Returns
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
mockIdstring
Returns
GetStub(string, string)
Get a single stub by id.
public BowireRecordingStep? GetStub(string mockId, string stubId)
Parameters
Returns
GetStubs(string)
List the stubs (recording steps) of a running mock.
public IReadOnlyList<BowireRecordingStep>? GetStubs(string mockId)
Parameters
mockIdstring
Returns
List()
Snapshot of every running mock. Order undefined; UI sorts by StartedAtUtc.
public IReadOnlyCollection<MockHostHandle> List()
Returns
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
Returns
ResetScenarios(string)
Reset all scenarios to Started. False when not running.
public bool ResetScenarios(string mockId)
Parameters
mockIdstring
Returns
ResetStubs(string)
Restore a running mock's stubs to its baseline recording. False when not running.
public bool ResetStubs(string mockId)
Parameters
mockIdstring
Returns
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
Returns
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
recordingJsonstringSingle recording document (NOT the {"recordings":[...]} envelope).
recordingIdstringStable 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.
labelstringDisplay label (recording name or operator- supplied alias).
portintRequested port. 0 = use the rolling allocator; any positive value pins the mock to that port (and fails the call if the port is busy).
ctCancellationTokenCancellation.
Returns
StopAsync(string, CancellationToken)
public Task<bool> StopAsync(string mockId, CancellationToken ct)
Parameters
mockIdstringctCancellationToken
Returns
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
mockIdstringfaultsFaultRuleSet
Returns
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
mockIdstringstubIdstringstubBowireRecordingStep