pub struct ShardingApi;Expand description
ShardingApi
Public API façade for shard placement and inspection.
Responsibilities:
- Expose read-only sharding queries
- Expose sharding workflows (assignment / planning)
- Normalize internal
ErrorintoPublicError
Does not:
- Contain business logic
- Interpret policies
- Access storage directly
Implementations§
Source§impl ShardingApi
impl ShardingApi
Sourcepub fn lookup_tenant(pool: &str, tenant: &str) -> Option<Principal>
pub fn lookup_tenant(pool: &str, tenant: &str) -> Option<Principal>
Lookup the shard assigned to a tenant in a pool, if any.
Sourcepub fn require_tenant_shard(
pool: &str,
tenant: impl AsRef<str>,
) -> Result<Principal, PublicError>
pub fn require_tenant_shard( pool: &str, tenant: impl AsRef<str>, ) -> Result<Principal, PublicError>
Return the shard for a tenant, or a PublicError if unassigned.
Sourcepub fn registry_view() -> ShardingRegistryView
pub fn registry_view() -> ShardingRegistryView
Return a view of the full sharding registry.
Sourcepub fn tenants_view(pool: &str, shard: Principal) -> ShardingTenantsView
pub fn tenants_view(pool: &str, shard: Principal) -> ShardingTenantsView
Return all tenants currently assigned to a shard.
Sourcepub async fn assign_to_pool(
pool: &str,
tenant: impl AsRef<str>,
) -> Result<Principal, PublicError>
pub async fn assign_to_pool( pool: &str, tenant: impl AsRef<str>, ) -> Result<Principal, PublicError>
Assign a tenant to a shard in the given pool.
This performs validation, selection, and persistence.
Sourcepub fn plan_assign_to_pool(
pool: &str,
tenant: impl AsRef<str>,
) -> Result<ShardingPlanStateView, PublicError>
pub fn plan_assign_to_pool( pool: &str, tenant: impl AsRef<str>, ) -> Result<ShardingPlanStateView, PublicError>
Perform a dry-run shard assignment and return the resulting plan.
Auto Trait Implementations§
impl Freeze for ShardingApi
impl RefUnwindSafe for ShardingApi
impl Send for ShardingApi
impl Sync for ShardingApi
impl Unpin for ShardingApi
impl UnwindSafe for ShardingApi
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more