Class ReverseProxyRegistry

Namespace
Kuestenlogik.Bowire.Interceptor
Assembly
Kuestenlogik.Bowire.Interceptor.dll

Process-wide registry of BowireReverseProxyHost instances started from the workbench's Tools → Reverse-proxy surface (#153 UI Phase). Hosts started here die when the surrounding Bowire process exits — the registry hooks ApplicationStopping to stop and dispose every entry so a Ctrl-C on the parent doesn't leak Kestrel listeners.

public sealed class ReverseProxyRegistry : IAsyncDisposable
Inheritance
ReverseProxyRegistry
Implements
Inherited Members

Remarks

Keying by edge port (the bound TCP port) is intentional: it's the stable identifier the operator sees in the UI ("Running on :5200 → upstream"). A second Start request that names a port already in flight returns a 409 in BowireToolsEndpoints so the operator gets a clear "pick another port" signal instead of a silent overwrite.

Lifetimes here are bounded by the host process — by design. The reverse-proxy is a transient developer tool, not a long-running production gateway; a UI-driven persist-across- restart story would invite operators to use Bowire as a production proxy, which is out of scope for the workbench (the standalone bowire proxy CLI covers that surface).

Constructors

ReverseProxyRegistry(IHostApplicationLifetime?, ILogger<ReverseProxyRegistry>?)

Construct the registry + register a graceful-shutdown hook so every started proxy stops when the host stops. The lifetime is optional so unit tests can instantiate the registry without faking a full ASP.NET host.

public ReverseProxyRegistry(IHostApplicationLifetime? lifetime = null, ILogger<ReverseProxyRegistry>? logger = null)

Parameters

lifetime IHostApplicationLifetime
logger ILogger<ReverseProxyRegistry>

Methods

DisposeAsync()

public ValueTask DisposeAsync()

Returns

ValueTask

Get(int)

Look up a running entry by edge port.

public ReverseProxyRegistryEntry? Get(int port)

Parameters

port int

Returns

ReverseProxyRegistryEntry

Snapshot()

Snapshot of every running proxy keyed by edge port.

public IReadOnlyCollection<ReverseProxyRegistryEntry> Snapshot()

Returns

IReadOnlyCollection<ReverseProxyRegistryEntry>

StopAllAsync(CancellationToken)

Stop every registered entry. Used by the ApplicationStopping hook and the "Stop all" button in the workbench's Settings → Tools list.

public Task<int> StopAllAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

Returns

Task<int>

StopAsync(int, CancellationToken)

Stop + remove the entry for port. No-op when no such entry exists (idempotent — repeated Stop clicks from the UI shouldn't error).

public Task<bool> StopAsync(int port, CancellationToken cancellationToken = default)

Parameters

port int
cancellationToken CancellationToken

Returns

Task<bool>

TryAdd(ReverseProxyRegistryEntry)

Try to register a freshly-started host. Returns true when the port slot was free, false when an entry already owns that port (caller surfaces a 409).

public bool TryAdd(ReverseProxyRegistryEntry entry)

Parameters

entry ReverseProxyRegistryEntry

Returns

bool