-
Notifications
You must be signed in to change notification settings - Fork 5
Open
Description
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.ManagerhasWithSettingsCheckInterval+revalidatePoolSettingsgoroutine ✅tmmongo.Managerdoes NOT have this option ❌
Proposed Implementation
Port the revalidation logic from tmpostgres.Manager to tmmongo.Manager:
- Add
settingsCheckInterval time.Durationfield - Add
lastSettingsCheck map[string]time.Timeper-tenant tracking - Add
WithSettingsCheckInterval(d time.Duration) Option - In
GetConnection, check if interval has passed → spawn goroutine revalidatePoolSettingscallsclient.GetTenantConfig→ ifTenantSuspendedError→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
-
tmmongo.WithSettingsCheckIntervaloption available - Suspended/purged tenants evicted from MongoDB pool after interval
- Next request creates fresh connection with new credentials
- Tests covering revalidation and eviction
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels