Interface ITsakSaveInterceptors

Assembly: redb.Tsak.Core.dll

Save interceptors a module subscribes for the life of its route context. The host keeps the redb service and its
DI container to itself; a module reaches this service through its context instead:
public override async Task<IRouteContext> InitializeAsync(IRouteContext context)
{
context.GetService<ITsakSaveInterceptors>()?.Add(new NotifyFrontInterceptor());
...
}
The context holds the subscription: when Tsak removes the context (the module is unloaded, or reloaded and its
context created anew) every interceptor it added is removed before the module's AssemblyLoadContext unloads, so
the module needs no cleanup of its own. Stopping the context keeps them, as it keeps the routes.

What an interceptor added here sees: every save and delete of the worker made through the host's redb service and
the named redb instances of the contexts, including those of other modules. An exception thrown from
or therefore
cancels any save or delete of the worker, not only the module's own. The semantics are those of
: SavedAsync after the commit, inside the transaction within
ExecuteAtomicAsync.


The service is in the context only when the host runs redb (Tsak:Redb:Provider is set); without it
GetService returns null.

public interface ITsakSaveInterceptors

Methods

Add(IRedbSaveInterceptor)

Subscribes interceptor until the context is removed. Dispose the result to remove it

IDisposable Add(IRedbSaveInterceptor interceptor)