Overview
Extend MultiTenantClient to support a true connection pool: each tenant's client is kept alive up to a TTL, health-checked periodically, and evicted on failure or expiry. This is critical for server-side usage (e.g. a Next.js API route serving many tenants).
Requirements
MultiTenantClient({ maxClients: number, ttlMs: number, healthCheckIntervalMs: number })
getClient(tenantId: string, config?: StellarSplitClientConfig): StellarSplitClient — returns existing or creates new client
- LRU eviction when
maxClients is reached
- TTL-based eviction: clients older than
ttlMs are evicted on next access
- Background health check: pings each client's RPC every
healthCheckIntervalMs; evicts unhealthy clients
pool.stats(): PoolStats returning { size, hits, misses, evictions, healthCheckFailures }
- Write tests covering LRU eviction, TTL expiry, health check eviction, and pool stats accuracy
Acceptance Criteria
Definition of Done
All CI checks must pass before the PR is reviewed.
Overview
Extend
MultiTenantClientto support a true connection pool: each tenant's client is kept alive up to a TTL, health-checked periodically, and evicted on failure or expiry. This is critical for server-side usage (e.g. a Next.js API route serving many tenants).Requirements
MultiTenantClient({ maxClients: number, ttlMs: number, healthCheckIntervalMs: number })getClient(tenantId: string, config?: StellarSplitClientConfig): StellarSplitClient— returns existing or creates new clientmaxClientsis reachedttlMsare evicted on next accesshealthCheckIntervalMs; evicts unhealthy clientspool.stats(): PoolStatsreturning{ size, hits, misses, evictions, healthCheckFailures }Acceptance Criteria
maxClientslimitpool.stats()returns accurate metricsnpm testpasses with zero failuresDefinition of Done
All CI checks must pass before the PR is reviewed.