Class EventIndexRegistry
A first-class, reusable host dispatch index (issue #50). A host registers a subscription kernel together
with its generated IndexedPredicates; the registry recomputes them from verified IR and
compiles them into an
EventIndexMatcher<TEvent> (precompiled getters, no per-event reflection) and, when the host
publishes an event, runs the cheap index check before entering the sandbox. Events the index
rejects never reach the verified IR; survivors are dispatched to InstalledKernel as the
correctness authority — the verified ShouldHandle still runs after a matching index check because
package-supplied coverage metadata is not trusted across the manifest boundary.
This is the "register a subscription and get index-based prefiltering without writing your own matcher"
surface. Subscriptions whose predicates touch no indexed field are rejected by Register<TEvent>(IPluginEventAdapter<TEvent>, InstalledKernel, IReadOnlyList<IndexedPredicate>, bool)
(returns false) so the host can leave them on its broad pipeline.
public sealed class EventIndexRegistry
- Inheritance
-
EventIndexRegistry
- Inherited Members
Constructors
EventIndexRegistry(Action<SubscriptionDeliveryFault>?)
public EventIndexRegistry(Action<SubscriptionDeliveryFault>? onFault = null)
Parameters
onFaultAction<SubscriptionDeliveryFault>
Properties
Stats
Aggregate prefilter diagnostics across every published event and registered subscription.
public EventIndexStats Stats { get; }
Property Value
Methods
DrainAsync()
Awaits every in-flight dispatch launched by Publish<TEvent>(TEvent, CancellationToken) (e.g. on host shutdown).
public Task DrainAsync()
Returns
Publish<TEvent>(TEvent, CancellationToken)
Runs every registered TEvent subscription's cheap index check against
value; survivors are dispatched to the verified IR fire-and-forget (the host's
broad pipeline keeps non-indexed subscriptions). Prefilter counters update synchronously.
public void Publish<TEvent>(TEvent value, CancellationToken cancellationToken = default)
Parameters
valueTEventcancellationTokenCancellationToken
Type Parameters
TEvent
Register<TEvent>(IPluginEventAdapter<TEvent>, InstalledKernel, IReadOnlyList<IndexedPredicate>, bool)
Registers kernel as an indexed subscription for TEvent.
The matching predicates are recomputed from the kernel's verified ShouldHandle IR; the
predicates and indexCoversPredicate arguments are the package's
untrusted manifest claims and are intentionally not read here. Returns false (registering
nothing) when none of the recomputed predicates map onto an EventIndexKeyAttribute field
— the caller should keep such a subscription on its broad pipeline. Returns true when the
subscription is now served from the index.
public bool Register<TEvent>(IPluginEventAdapter<TEvent> adapter, InstalledKernel kernel, IReadOnlyList<IndexedPredicate> predicates, bool indexCoversPredicate)
Parameters
adapterIPluginEventAdapter<TEvent>kernelInstalledKernelpredicatesIReadOnlyList<IndexedPredicate>indexCoversPredicatebool
Returns
Type Parameters
TEvent
Unregister(InstalledKernel)
Removes every registration owned by kernel (e.g. when a host uninstalls it).
public void Unregister(InstalledKernel kernel)
Parameters
kernelInstalledKernel