Run a function once per provisioned tenant schema, with that tenant's search_path pinned for the duration (ZZP-86).
This is the background-job analogue of the HTTP wrap-tenant-schema
middleware: jobs that must touch tenant-scoped entity tables iterate every
provisioned tenant_<slug> schema and run their work inside each, so the
same connection-pinned tenant isolation applies as on the request path.
Without this, a job calling a repo with the pooled context runs under the
default search_path = public and only sees the (now empty) public tables.
Run a function once per provisioned tenant schema, with that tenant's search_path pinned for the duration (ZZP-86). This is the background-job analogue of the HTTP `wrap-tenant-schema` middleware: jobs that must touch tenant-scoped entity tables iterate every provisioned `tenant_<slug>` schema and run their work inside each, so the same connection-pinned tenant isolation applies as on the request path. Without this, a job calling a repo with the pooled context runs under the default `search_path = public` and only sees the (now empty) public tables.
(for-each-tenant-schema schema-provider db-ctx f)For each provisioned tenant schema, run (f schema-name) inside that
schema's search_path via the schema provider's with-tenant-schema.
Per-tenant failures are isolated and counted — one tenant's error never aborts the others.
Args:
schema-provider - an ITenantSchemaProvider
db-ctx - database context ({:datasource ... :adapter ...})
f - 1-arg fn, receives the schema name; runs inside the
tenant's pinned connection + search_path
Returns: {:processed n :failed n :results [<f results for succeeded tenants>]}
For each provisioned tenant schema, run `(f schema-name)` inside that
schema's search_path via the schema provider's `with-tenant-schema`.
Per-tenant failures are isolated and counted — one tenant's error never
aborts the others.
Args:
schema-provider - an `ITenantSchemaProvider`
db-ctx - database context (`{:datasource ... :adapter ...}`)
f - 1-arg fn, receives the schema name; runs inside the
tenant's pinned connection + search_path
Returns:
{:processed n :failed n :results [<f results for succeeded tenants>]}cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |