Skip to content

TenantManager Class

Judges each change of the tenants by the checks the server runs at startup, writes it to the store and has the catalog read the store again, so the change is served by this instance at once where it can be.

C#
public sealed class TenantManager : Abblix.Oidc.Server.Features.MultiTenancy.ITenantManager

Inheritance System.Object → TenantManager

Implements ITenantManager

Remarks

The changes of this instance are made one at a time, so two of them cannot each pass the checks against a list the other is about to change.

Constructors

TenantManager(ILogger<TenantManager>, ITenantStore, IEnumerable<ITenantsCheck>, StoreTenantCatalog, IOptions<OidcOptions>, ITenantStoreWriter) Constructor

Judges each change of the tenants by the checks the server runs at startup, writes it to the store and has the catalog read the store again, so the change is served by this instance at once where it can be.

C#
public TenantManager(Microsoft.Extensions.Logging.ILogger<Abblix.Oidc.Server.Features.MultiTenancy.TenantManager> logger, Abblix.Oidc.Server.Features.MultiTenancy.ITenantStore store, System.Collections.Generic.IEnumerable<Abblix.Oidc.Server.Features.MultiTenancy.ITenantsCheck> checks, Abblix.Oidc.Server.Features.MultiTenancy.StoreTenantCatalog catalog, Microsoft.Extensions.Options.IOptions<Abblix.Oidc.Server.Common.Configuration.OidcOptions> options, Abblix.Oidc.Server.Features.MultiTenancy.ITenantStoreWriter? writer=null);

Parameters

logger Microsoft.Extensions.Logging.ILogger<TenantManager>

Records a reading that failed after a change was written.

store ITenantStore

Where the tenants are read from.

checks System.Collections.Generic.IEnumerable<ITenantsCheck>

The checks of the tenant list, the ones the catalog runs at every reading.

catalog StoreTenantCatalog

Reads the store again once a change is written.

options Microsoft.Extensions.Options.IOptions<OidcOptions>

The server's own settings, the checks judge a tenant with.

writer ITenantStoreWriter

Writes the changes to the store; none when the host writes to its store by other means.

Remarks

The changes of this instance are made one at a time, so two of them cannot each pass the checks against a list the other is about to change.

Methods

TenantManager.CreateAsync(TenantDefinition, CancellationToken) Method

Creates tenant under a new generation, so nothing kept for an earlier tenant of its id carries over to it.

C#
public System.Threading.Tasks.Task<Abblix.Utils.Result<Abblix.Oidc.Server.Features.MultiTenancy.StoredTenant,Abblix.Oidc.Server.Features.MultiTenancy.TenantChangeRefusal>> CreateAsync(Abblix.Oidc.Server.Features.MultiTenancy.TenantDefinition tenant, System.Threading.CancellationToken cancellationToken);

Parameters

tenant TenantDefinition

The tenant to create; its generation is assigned here.

cancellationToken System.Threading.CancellationToken

Cancels the change until it is written; after that it only stops the wait for this instance to serve the change, which is then reported as made.

Implements CreateAsync(TenantDefinition, CancellationToken)

Returns

System.Threading.Tasks.Task<Abblix.Utils.Result<StoredTenant,TenantChangeRefusal>>
The tenant as stored, or why it was refused.

Exceptions

System.InvalidOperationException
The store registers no ITenantStoreWriter.

TenantManager.RemoveAsync(string, string, CancellationToken) Method

Removes the tenant stored under tenantId, while it is stored at version.

C#
public System.Threading.Tasks.Task<Abblix.Utils.Result<Abblix.Oidc.Server.Features.MultiTenancy.StoredTenant,Abblix.Oidc.Server.Features.MultiTenancy.TenantChangeRefusal>> RemoveAsync(string tenantId, string version, System.Threading.CancellationToken cancellationToken);

Parameters

tenantId System.String

The id of the tenant to remove.

version System.String

The version the tenant was read at.

cancellationToken System.Threading.CancellationToken

Cancels the change until it is written; after that it only stops the wait for this instance to serve the change, which is then reported as made.

Implements RemoveAsync(string, string, CancellationToken)

Returns

System.Threading.Tasks.Task<Abblix.Utils.Result<StoredTenant,TenantChangeRefusal>>
The tenant as it was stored, or why the removal was refused.

Exceptions

System.InvalidOperationException
The store registers no ITenantStoreWriter.

TenantManager.UpdateAsync(TenantDefinition, string, CancellationToken) Method

Replaces the tenant stored under the id of tenant, keeping its generation, while it is stored at version.

C#
public System.Threading.Tasks.Task<Abblix.Utils.Result<Abblix.Oidc.Server.Features.MultiTenancy.StoredTenant,Abblix.Oidc.Server.Features.MultiTenancy.TenantChangeRefusal>> UpdateAsync(Abblix.Oidc.Server.Features.MultiTenancy.TenantDefinition tenant, string version, System.Threading.CancellationToken cancellationToken);

Parameters

tenant TenantDefinition

The tenant as it is to be; a generation it names is not taken, the stored one is kept.

version System.String

The version the tenant was read at.

cancellationToken System.Threading.CancellationToken

Cancels the change until it is written; after that it only stops the wait for this instance to serve the change, which is then reported as made.

Implements UpdateAsync(TenantDefinition, string, CancellationToken)

Returns

System.Threading.Tasks.Task<Abblix.Utils.Result<StoredTenant,TenantChangeRefusal>>
The tenant as stored, or why it was refused.

Exceptions

System.InvalidOperationException
The store registers no ITenantStoreWriter.