Summary
Add WithSettingsCheckInterval option to tmmongo.Manager (MongoDB tenant manager), matching the existing implementation in tmpostgres.Manager.
Problem
When a tenant is suspended or purged, the PostgreSQL manager detects this via periodic revalidation and evicts the cached connection. The MongoDB manager has no such mechanism — cached connections remain stale until pod restart.
This affects all components using tmmongo.Manager:
- CRM (MongoDB only)
- Onboarding (MongoDB manager)
- Transaction (MongoDB manager)
Current State
tmpostgres.Manager has WithSettingsCheckInterval + revalidatePoolSettings goroutine ✅
tmmongo.Manager does NOT have this option ❌
Proposed Implementation
Port the revalidation logic from tmpostgres.Manager to tmmongo.Manager:
- Add
settingsCheckInterval time.Duration field
- Add
lastSettingsCheck map[string]time.Time per-tenant tracking
- Add
WithSettingsCheckInterval(d time.Duration) Option
- In
GetConnection, check if interval has passed → spawn goroutine
revalidatePoolSettings calls client.GetTenantConfig → if TenantSuspendedError → CloseConnection
Behavior
- Per-tenant, lazy evaluation (only when requests arrive)
- Fire-and-forget goroutine (non-blocking)
- Default: 30s (same as PostgreSQL)
- Configurable via the option
Acceptance Criteria
Summary
Add
WithSettingsCheckIntervaloption totmmongo.Manager(MongoDB tenant manager), matching the existing implementation intmpostgres.Manager.Problem
When a tenant is suspended or purged, the PostgreSQL manager detects this via periodic revalidation and evicts the cached connection. The MongoDB manager has no such mechanism — cached connections remain stale until pod restart.
This affects all components using
tmmongo.Manager:Current State
tmpostgres.ManagerhasWithSettingsCheckInterval+revalidatePoolSettingsgoroutine ✅tmmongo.Managerdoes NOT have this option ❌Proposed Implementation
Port the revalidation logic from
tmpostgres.Managertotmmongo.Manager:settingsCheckInterval time.DurationfieldlastSettingsCheck map[string]time.Timeper-tenant trackingWithSettingsCheckInterval(d time.Duration) OptionGetConnection, check if interval has passed → spawn goroutinerevalidatePoolSettingscallsclient.GetTenantConfig→ ifTenantSuspendedError→CloseConnectionBehavior
Acceptance Criteria
tmmongo.WithSettingsCheckIntervaloption available