Interface IBowireMockTransportHost
- Namespace
- Kuestenlogik.Bowire.Mocking
- Assembly
- Kuestenlogik.Bowire.dll
Plugin-contributed transport host that the Bowire mock server starts alongside its main HTTP listener — for protocols that need their own listener on a separate port (MQTT-broker today, AMQP / DDS / NNG / raw-socket later). Plugins implement this in their own assembly so the heavy transport library (e.g. MQTTnet) hangs only on the protocol-plugin package, not on Kuestenlogik.Bowire.Mock.
public interface IBowireMockTransportHost
Remarks
Discovered alongside IBowireMockEmitter via the
existing plugin-load pass; MockServerOptions.TransportHosts
receives every concrete instance the host's plugin directory yields.
The mock server iterates them at startup, asks each whether the
loaded recording has relevant steps via ShouldStart(BowireRecording),
and starts the ones that say yes.
The lifetime contract:
- StartAsync(BowireRecording, MockTransportContext, CancellationToken) is called once during MockServer startup, after the recording is loaded but before the HTTP listener accepts traffic. Return the port the transport actually bound (or 0 when the transport doesn't have a meaningful port number).
- StopAsync(CancellationToken) is called once during MockServer shutdown. Hosts must shut their transport down cleanly so OS-level ports release for the next test run.
Properties
Id
Stable transport id surfaced in logs and in
MockServer.TransportPorts. Use the same id the recording
step's protocol field carries, lower-case (e.g.
"mqtt", "amqp").
string Id { get; }
Property Value
Methods
ShouldStart(BowireRecording)
Decide whether StartAsync(BowireRecording, MockTransportContext, CancellationToken) should be called for the
given recording — typically by scanning for steps whose
protocol matches Id. Hosts that return
false are skipped silently (no port allocation, no log
noise).
bool ShouldStart(BowireRecording recording)
Parameters
recordingBowireRecording
Returns
StartAsync(BowireRecording, MockTransportContext, CancellationToken)
Start the transport listener. Implementations are responsible for binding the port (using RequestedPort when non-zero, or picking an OS-assigned port when zero) and returning the actually-bound port number.
Task<int> StartAsync(BowireRecording recording, MockTransportContext context, CancellationToken ct)
Parameters
recordingBowireRecordingcontextMockTransportContextctCancellationToken
Returns
StopAsync(CancellationToken)
Stop the transport. Called during MockServer shutdown — close listeners, release resources, drop scheduled tasks.
Task StopAsync(CancellationToken ct)