Interface IRedbSaveInterceptorRegistry

Assembly: redb.Core.dll

Save interceptors added and removed while the process runs: code that cannot reach the DI container the redb
service was built from (a module loaded into its own AssemblyLoadContext, for instance) subscribes here for as
long as it lives. Registered as a singleton by AddRedb and AddRedbPro (TryAdd: an instance put into
the container before is kept, so several containers may share one registry); resolve it as
IRedbSaveInterceptorRegistry.

An interceptor from the registry runs after the ones registered in DI, in the order of
, with exactly the semantics of (Saving and Deleting before
the transaction, Saved and Deleted after the commit, everything inside an ExecuteAtomicAsync scope).


Scope of a subscription: it sees EVERY save and delete of the process made through a redb service whose container
holds this registry, scopes already open included, other modules' saves included, and the named instances of
RedbInstanceFactory built over the same registry. An exception thrown from SavingAsync or
DeletingAsync therefore cancels any save or delete of the process, not only the subscriber's own.


A subscription is picked up by the next save or delete; an operation already running keeps the set it started
with, so its Saving and Saved (Deleting and Deleted) always reach the same interceptors. Disposing the returned
handle removes the interceptor for every operation that starts afterwards, and the registry keeps no reference
to it: an AssemblyLoadContext that held the interceptor's type can unload once its running operations end.

public interface IRedbSaveInterceptorRegistry

Properties

Current

The interceptors subscribed right now, in the order they were added. An immutable snapshot.

IReadOnlyList<IRedbSaveInterceptor> Current { get; }

Methods

Add(IRedbSaveInterceptor)

Subscribes interceptor. Dispose the result to remove it; disposing twice, or from another

IDisposable Add(IRedbSaveInterceptor interceptor)