ITenantActivity<TKey> interface
Namespace: Tenantry · Package: Tenantry.Core · API reference
Whether a tenant may have work run for it, as the registered ITenantActivityValidator<TKey>s decide. A tenant is active when every validator allows it, and always when none is registered.
Registered as a singleton by AddTenantry. Tenantry consults it in ITenantScopeFactory<TKey>.RunInScopeAsync and, in Tenantry.AspNetCore, for each request. Tenantry.Pro's background services, schedulers and message integrations consult it too.
ITenantScopeFactory<TKey>.CreateScope does not: it takes a tenant you already hold, for work such as provisioning and migrations that must reach suspended tenants. Check this first when you iterate tenants for work of your own.
public interface ITenantActivity<TKey> where TKey : IEquatable<TKey>, IParsable<TKey>Type parameters
TKey: The tenant identifier type.
Methods
IsActiveAsync(ITenantDescriptor<TKey>, CancellationToken)
Returns true when every validator allows tenant.
ValueTask<bool> IsActiveAsync(ITenantDescriptor<TKey> tenant, CancellationToken cancellationToken = default)Parameters:
tenantITenantDescriptor<TKey>: The tenant.cancellationTokenCancellationToken: Cancels the check.
Returns: ValueTask<bool>
ThrowIfInactiveAsync(ITenantDescriptor<TKey>, CancellationToken)
Throws TenantInactiveException unless every validator allows tenant.
ValueTask ThrowIfInactiveAsync(ITenantDescriptor<TKey> tenant, CancellationToken cancellationToken = default)Parameters:
tenantITenantDescriptor<TKey>: The tenant.cancellationTokenCancellationToken: Cancels the check.
Returns: ValueTask
Exceptions:
TenantInactiveException: A validator refused the tenant.