Class InterceptedFlowStore

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

In-memory ring buffer of InterceptedFlows plus a fan-out channel for live subscribers (Workbench "Intercepted" rail over SSE). Bounded so a long-running host with app.UseBowireInterceptor() doesn't grow unbounded — once Capacity flows are stored the oldest one is evicted before the new one is added.

public sealed class InterceptedFlowStore
Inheritance
InterceptedFlowStore
Inherited Members

Remarks

Mirrors CapturedFlowStore on purpose: same TryWrite-never-blocks semantics, same DropOldest channel policy, same Snapshot / Get / Subscribe surface. Two separate stores (one for proxy traffic, one for in-process intercept traffic) keep the rails independent — turning the interceptor on never pollutes the proxy rail's snapshot, and clearing one doesn't clear the other.

Registered as a singleton by Kuestenlogik.Bowire.Interceptor.BowireInterceptorMiddleware's service-collection extension. When the host never opts in (no UseBowireInterceptor() call), the singleton is still registered but stays empty — the rail's "no traffic yet" empty state covers that case without spending any per-request cost in the pipeline.

Constructors

InterceptedFlowStore(int)

public InterceptedFlowStore(int capacity = 1000)

Parameters

capacity int

Properties

Capacity

Maximum number of flows retained. Older flows are evicted FIFO.

public int Capacity { get; }

Property Value

int

Methods

Add(InterceptedFlow)

Record a finished flow + fan it out to live subscribers.

public void Add(InterceptedFlow flow)

Parameters

flow InterceptedFlow

Clear()

Drop everything (workbench "Clear all" button + tests).

public void Clear()

Get(long)

Lookup a flow by id (newest-first scan; small N).

public InterceptedFlow? Get(long id)

Parameters

id long

Returns

InterceptedFlow

NextId()

Allocate the next monotonic flow id. Called before recording the request so a half-captured "request seen" event can be correlated with the eventual "response landed" event by Phase B's auto-record hook.

public long NextId()

Returns

long

Snapshot()

Newest-first snapshot of currently retained flows.

public IReadOnlyList<InterceptedFlow> Snapshot()

Returns

IReadOnlyList<InterceptedFlow>

Subscribe(CancellationToken)

Subscribe to live flow events. Returns a channel reader that yields newly-recorded flows until cancellation. Slow consumers silently drop the oldest queued event instead of back-pressuring the intercept hot path.

public ChannelReader<InterceptedFlow> Subscribe(CancellationToken cancellationToken)

Parameters

cancellationToken CancellationToken

Returns

ChannelReader<InterceptedFlow>