Skip to content

feat: extend MultiTenantClient with LRU, TTL, health checks, and pool…#432

Open
Eromosele0110 wants to merge 1 commit into
Stellar-split:mainfrom
Eromosele0110:feature/multi-tenant-connection-pool
Open

feat: extend MultiTenantClient with LRU, TTL, health checks, and pool…#432
Eromosele0110 wants to merge 1 commit into
Stellar-split:mainfrom
Eromosele0110:feature/multi-tenant-connection-pool

Conversation

@Eromosele0110

Copy link
Copy Markdown
Contributor

… stats

  • Rewrote MultiTenantClient to support a full connection pool
  • Constructor now accepts PoolOptions: maxClients, ttlMs, healthCheckIntervalMs
  • LRU eviction: Map insertion-order used for O(1) LRU; re-inserted on every hit
  • TTL eviction: checked on each getClient() access, expired entries recreated
  • Background health checks: setInterval pings each client's RPC via SorobanRpc.Server; unhealthy clients (getLatestLedger throws) are evicted, failures counted separately
  • pool.stats() returns PoolStats: { size, hits, misses, evictions, healthCheckFailures }
  • pool.destroy() clears the interval timer and evicts all clients
  • getClient() accepts optional config override as second argument
  • Exported PoolOptions and PoolStats from src/index.ts
  • 25 tests covering: LRU order, maxClients boundary, TTL expiry, independent TTLs, health-check eviction, mixed-pool sweep, destroy() timer stop, stats accuracy
  • Fixed pre-existing bugs on main: VersionInfo missing closing brace in types.ts, duplicate LedgerAdapter export in index.ts, version.ts string|string[] split, client.ts missing InvoiceLifecycleHooks/_hooks, client.test.ts await-in-non-async and wrong error count assertions
  • close Implement a multi-tenant client pool with TTL-based eviction and health checks #423

… stats

- Rewrote MultiTenantClient to support a full connection pool
- Constructor now accepts PoolOptions: maxClients, ttlMs, healthCheckIntervalMs
- LRU eviction: Map insertion-order used for O(1) LRU; re-inserted on every hit
- TTL eviction: checked on each getClient() access, expired entries recreated
- Background health checks: setInterval pings each client's RPC via SorobanRpc.Server;
  unhealthy clients (getLatestLedger throws) are evicted, failures counted separately
- pool.stats() returns PoolStats: { size, hits, misses, evictions, healthCheckFailures }
- pool.destroy() clears the interval timer and evicts all clients
- getClient() accepts optional config override as second argument
- Exported PoolOptions and PoolStats from src/index.ts
- 25 tests covering: LRU order, maxClients boundary, TTL expiry, independent TTLs,
  health-check eviction, mixed-pool sweep, destroy() timer stop, stats accuracy
- Fixed pre-existing bugs on main: VersionInfo missing closing brace in types.ts,
  duplicate LedgerAdapter export in index.ts, version.ts string|string[] split,
  client.ts missing InvoiceLifecycleHooks/_hooks, client.test.ts await-in-non-async
  and wrong error count assertions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement a multi-tenant client pool with TTL-based eviction and health checks

1 participant