Tenant Bridges And Cross-Tenant Flows
Cross-tenant flows need explicit design because tenant boundaries are ownership and security boundaries.
Direct Shared Access
Use direct shared access when two tenants can agree on the same model and no translation is required.
The grant is always the same shape (write narrow, consume wide): Tenant A publishes in its own namespace and grants
Tenant B consume on that one topic, never on a namespace and never publish. The topic keeps its own name,
<Model>[_<purpose>]; B's route reads it through its own subscription, named after its route id, so the broker shows B
as a subscription on A's topic. When the content is for B alone, A may choose B's tenant slug as the purpose
(persistent://tenant-a/finance/InvoiceV1_tenant-b), but that is A's choice as the publisher, never a second suffix
after another purpose.
A approves the grant: it is an entry in A's Pulsar file in klok/environment/klok-environment-setup. A developer of B
requests consume in klok.dev, A's TenantAdmin or the DomainAdmin of the topic's namespace approves it there, and
klok.dev merges the entry into A's file and applies it to the broker; a merge request that A merges by hand in GitLab is
the same approval (Topics On The Klok Broker). Data
flowing back from B to A is B's topic, in B's namespace, with A granted consume.
B's route cannot write the _DLQ of A's topic, since B never publishes in A's namespace. A message whose retries are
exhausted is therefore not quarantined but handled by the route's failure.unresolved setting. Where dead letters of
another tenant's topic should go is open in
klok/framework/klok-common#11.
Benefits:
- Low latency.
- No duplicate data.
- One source of truth.
Risks:
- Tenant B becomes coupled to Tenant A's contract.
- Access control must be precise.
- Operational ownership must be clear.
Tenant Bridge With Translation
Use a bridge when the receiving tenant needs a different model, strict isolation, or a translated contract.
Benefits:
- Data models can evolve independently.
- Each tenant receives the contract it owns.
- Translation is explicit and observable.
Costs:
- More code and operations.
- Additional latency.
- Another route leg to test and monitor.
Design Questions
- Which tenant owns the source contract?
- Which tenant owns the target contract?
- Is translation required?
- Who operates the bridge?
- Where do logs and failure events go?
- Which service principal has access to which topics?
- Does the bridge create a copy that has data retention implications?