Skip to main content

TenantScopeProvider

Trait TenantScopeProvider 

Source
pub trait TenantScopeProvider: Send + Sync {
    // Required method
    fn with_scope<'life0, 'async_trait>(
        &'life0 self,
        tenant_id: i64,
        f: Pin<Box<dyn Future<Output = Result<(), Error>> + Send>>,
    ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

Injects tenant scope around job execution.

Implemented by the framework — injected at startup via Worker::with_tenant_scope(). The provider receives a tenant_id and a boxed future representing the job execution. It must resolve the tenant, establish a task-local scope, and run the future within it. Returns TenantNotFound error if the tenant ID does not resolve to a valid tenant.

Required Methods§

Source

fn with_scope<'life0, 'async_trait>( &'life0 self, tenant_id: i64, f: Pin<Box<dyn Future<Output = Result<(), Error>> + Send>>, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Run the given future within a tenant scope for the specified tenant.

Implementors§