ITenantProvisioningStep<TKey> interface
Namespace: Tenantry.Pro · Package: Tenantry.Pro · API reference
A step ITenantProvisioner<TKey> runs to provision a tenant. Add one with IProBuilder<TKey>.AddProvisioningStep<TStep>.
Each step is resolved from a new scope for the tenant being provisioned, which is disposed when the step ends, so it can take scoped services such as a DbContext in its constructor, and they read and write as that tenant. It is resolved before ITenantProvisioningStep<TKey>.AppliesTo is called, for every tenant: a service that cannot be created for tenants the step does not apply to (a context for a database they do not have, say) belongs in ITenantProvisioningStep<TKey>.ExecuteAsync, resolved from TenantProvisioningContext<TKey>.Scope.
Make it idempotent: recovering from a failure means provisioning the tenant again, which runs every step again, possibly after an earlier attempt did part of its work.
public interface ITenantProvisioningStep<TKey> where TKey : IEquatable<TKey>, IParsable<TKey>Type parameters
TKey: The tenant identifier type.
Methods
AppliesTo(TenantProvisioningContext<TKey>)
Returns whether the step applies to the tenant being provisioned; a step that does not is reported as TenantProvisioningStepStatus.Skipped. By default it applies to every tenant.
bool AppliesTo(TenantProvisioningContext<TKey> context)Parameters:
contextTenantProvisioningContext<TKey>: The tenant being provisioned.
Returns: bool: true to run the step for this tenant.
In mixed mode, TenantProvisioningContext<TKey>.Isolation says where the tenant's data lives, so a step can apply only to tenants with their own database, say.
ExecuteAsync(TenantProvisioningContext<TKey>, CancellationToken)
Runs the step for the tenant being provisioned.
Task ExecuteAsync(TenantProvisioningContext<TKey> context, CancellationToken cancellationToken)Parameters:
contextTenantProvisioningContext<TKey>: The tenant being provisioned, and its scope.cancellationTokenCancellationToken: Cancels provisioning.
Returns: Task
ITenantProvisioner<TKey> interface
Provisions a new tenant: runs every ITenantProvisioningStep<TKey>tenantry-pro-itenantprovisioningstep.md for it, in order, and reports each step's outcome.
ITenantSeeder<TKey> interface
Writes a new tenant's initial data, as a step of provisioning ITenantProvisioner<TKey>tenantry-pro-itenantprovisioner.md.