-
Notifications
You must be signed in to change notification settings - Fork 5
Closed
Description
Context
The MultiTenantConsumer currently supports two consumer start modes via the EagerStart config flag:
- Eager (default,
EagerStart=true): consumers are started immediately for all discovered tenants at startup and during sync. - Lazy (
EagerStart=false): consumers are only started on-demand viaEnsureConsumerStarted().
Problem
Lazy mode has zero callers across the entire codebase. No app (Midaz, Tenant Manager, or any other service) calls EnsureConsumerStarted() externally. The only trigger that would start consumers in lazy mode is the sync loop itself — which is exactly what eager already does.
This means:
- The
EagerStartflag and its conditional branches add complexity with no practical benefit today. - The public
EnsureConsumerStarted()API is exported but unused. - Two code paths need to be maintained and tested for a single effective behavior.
Proposed Changes
- Remove the
EagerStartconfig field fromMultiTenantConfig(or deprecate/ignore it). - Make eager the only behavior:
Run()always starts consumers for discovered tenants;syncTenants()always starts consumers for newly discovered tenants. - Remove the public
EnsureConsumerStarted()API — no external callers exist. - Keep
ensureConsumerStarted()as internal method — the double-check locking is still needed since sync can run concurrently. - Remove lazy-specific test cases and simplify existing tests that parameterize on
EagerStart.
Impact
- Simplifies the consumer startup flow to a single code path.
- Reduces config surface area.
- No behavioral change for any existing deployment (all use eager today).
Files Affected
commons/tenant-manager/consumer/multi_tenant.go— remove EagerStart field, simplifyRun()commons/tenant-manager/consumer/multi_tenant_consume.go— remove publicEnsureConsumerStarted()commons/tenant-manager/consumer/multi_tenant_sync.go— remove conditional branches ineagerStartKnownTenants()andsyncTenants()commons/tenant-manager/consumer/multi_tenant_stats.go— removeconnectionMode()helper- Test files — simplify parameterized tests
Note
If lazy mode becomes needed in the future (e.g., hundreds of tenants with sporadic activity), it can be re-added as a feature at that point. No need to carry the complexity now.
Requested by: @jeffersonRodrigues (CTO)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels