Μετάβαση στο περιεχόμενο

tenantSource

Αυτό το περιεχόμενο δεν είναι ακόμη διαθέσιμο στη γλώσσα σου.

const tenantSource: object

Defined in: tenant-scope.ts:57

The tenant as a context source, for createPipeline({ sources }) of @cqrs-ddd/pipeline and registerJobContext of @cqrs-ddd/pipeline-job-context: pipelines and jobs then take and restore this tenant.

readonly current: () => string | undefined = currentTenantId

Returns the current tenant: that of the innermost runWithTenant call or running pipeline, or undefined outside both. A running pipeline’s tenant is its context.tenantId, which it took from here when it started.

string | undefined

The current tenant id, or undefined for none.

runWithTenant('tenant_a', () => currentTenantId()); // 'tenant_a'

readonly run: <T>(tenantId, fn) => T = runWithTenant

Runs fn with tenantId as the current tenant for everything it calls, synchronously or asynchronously.

Use it where work enters the application, such as HTTP middleware or a queue job, or to change the tenant for part of a handler. A pipeline dispatched inside fn takes this tenant, and nested dispatches inherit it. A nested call replaces the tenant for its own callback only, and undefined runs fn with no tenant.

T

string | undefined

The tenant for the callback, or undefined for none.

() => T

The work to run.

T

What fn returns (its promise, for an async callback).

await runWithTenant(job.data.tenant, () => processBatch(job.data));
createPipeline({ sources: { tenantId: tenantSource } });