ZenithTenantScope class
A named, isolated container scope managed by ZenithScopeManager.
Each tenant (user account, anonymous session, background worker) gets its own ZenithTenantScope so nodes cannot leak across tenants. The scope:
- Wraps a private ZenithContainer.
- Tracks in-flight cancellation tokens and cancels them on disposal.
- Supports two-phase teardown via ZenithDrainable registration.
- Can be made isDormant (biometric lock) while keeping DB handles open.
- Implementers
Constructors
- ZenithTenantScope(String id)
-
Creates a ZenithTenantScope with
idand a fresh ZenithContainer.
Properties
- container → ZenithContainer
-
The isolated dependency container for this scope.
final
-
disposalComplete
→ Future<
void> -
Completion and errors of asynchronous cleanup started by dispose.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- id → String
-
The stable identifier for this scope (e.g. a user-id or 'anon_123').
final
- isClosing → bool
-
Whether teardown has begun. New scoped work is rejected while closing.
no setter
- isDisposed → bool
-
Whether this scope has been disposed.
no setter
- isDormant → bool
-
Whether this scope is dormant (biometric lock active).
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
dispose(
{bool purgeZeroize = false}) → void - Immediately disposes this scope: cancels tokens, fires dispose callbacks, optionally zeroizes Zeroizable nodes, then disposes the container.
-
drainAndDispose(
{Duration timeout = const Duration(milliseconds: 500), bool purgeZeroize = false}) → Future< void> - Awaits all registered ZenithDrainables then calls dispose.
-
drainOwnedScopes(
{required Duration timeout, required bool purgeZeroize}) → Future< void> - Override to drain currently owned child scopes before disposal.
-
listenToInterIsolateInvalidations(
String portName, {required void onInvalidate(String key)}) → void - Listens for ZenithInvalidateMessages on an IsolateNameServer port.
-
markActive(
) → void - Restores this scope from dormant state.
-
markDormant(
) → void - Puts this scope into dormant (biometric-locked) state.
-
maybeNode<
T> (ZenithKey< T> key) → ZenithNode<T> ? -
Returns the node for
keyif registered, or null. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
onDispose(
void callback()) → void -
Registers
callbackto be invoked when this scope is disposed. -
onDisposeAsync(
Future< void> callback()) → void - Registers resource cleanup that drainAndDispose will await. After disposal, await the returned disposalComplete for cleanup errors.
-
register<
T> (ZenithKey< T> key, T factory(), {ZenithLifetime lifetime = ZenithLifetime.scoped}) → void -
Registers
keywith afactoryin the container, tagging it withlifetimefor Captive Dependency Guard enforcement. -
registerDrainable(
ZenithDrainable drainable) → void -
Registers
drainableto be awaited during two-phase scope teardown. -
resolve<
T> (ZenithKey< T> key) → T -
Resolves the value for
keyfrom this scope's container. -
runGuarded(
Future< void> task()) → void -
Runs
taskguarded so that scope disposal automatically cancels it. -
runWithToken(
Future< void> task(ZenithCancellationToken token)) → void -
Runs
taskproviding a ZenithCancellationToken that is cancelled when this scope is disposed. -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited