Class TenantShardMapExtensions
Ambient-context bridging helpers for ITenantShardMap.
public static class TenantShardMapExtensions
- Inheritance
-
TenantShardMapExtensions
- Inherited Members
Methods
CurrentShard(ITenantShardMap, ITenantContext)
Resolves the ShardInfo for the current ambient tenant read from
context, delegating to GetShardInfo(string).
public static ShardInfo CurrentShard(this ITenantShardMap map, ITenantContext context)
Parameters
mapITenantShardMapThe tenant shard map.
contextITenantContextThe ambient tenant context.
Returns
- ShardInfo
The shard routing information for the ambient tenant.
Remarks
The tenant term is read through FromContext(ITenantContext), so a context that has resolved no tenant fails closed here. It is not routed as an unknown tenant: an unknown tenant is a real tenant the map has no entry for, which the map may answer with the configured default shard, whereas an unresolved context has no tenant to route at all. Routing it anyway silently returns whichever shard the map answers with, and the caller then reads and writes another tenant's data with nothing raised.
A caller that genuinely belongs to no tenant supplies UntenantedContext, whose tenant term is the reserved untenanted partition and routes like any other key.
Once a tenant term exists, fail-fast versus default-shard routing remains the underlying
ITenantShardMap's behavior (governed by ShardMapOptions.DefaultShardId):
the default shard when configured, otherwise a TenantShardNotFoundException.
Exceptions
- TenantRequiredException
contexthas resolved no tenant.- TenantShardNotFoundException
The tenant cannot be routed to a shard and no default shard is configured.