Skip to content

Refactor polling services to use MultiConnectionPoller base class#13

Merged
KIvanow merged 3 commits into
masterfrom
service-polling
Feb 4, 2026
Merged

Refactor polling services to use MultiConnectionPoller base class#13
KIvanow merged 3 commits into
masterfrom
service-polling

Conversation

@KIvanow
Copy link
Copy Markdown
Member

@KIvanow KIvanow commented Feb 3, 2026

Extract common multi-connection polling logic into a reusable abstract base class. Both HealthService and PrometheusService now extend MultiConnectionPoller, which provides:

  • Standardized polling loop with start/stop lifecycle
  • Parallel polling of all connected database instances
  • Error isolation between connections
  • Automatic cleanup when connections are removed
  • Re-entrance guard to prevent overlapping poll cycles

This reduces code duplication and ensures consistent polling behavior across services while preserving original functionality including the 5-second startup delay for health checks and webhook triggering after metrics collection.


Note

Medium Risk
Touches core periodic polling for health and metrics, so timing/coverage changes (especially polling disconnected connections and the new scheduler) could affect webhook firing and metric freshness if behavior diverges from the previous loops.

Overview
Refactors HealthService and PrometheusService to extend MultiConnectionPoller, removing their bespoke timer loops and centralizing multi-connection scheduling, parallel per-connection execution, overlap-guarding, and removal cleanup.

Adds shouldPollDisconnected() to the base poller and enables it for HealthService so health checks run for disconnected connections too, while preserving the 5s startup delay before polling begins. Prometheus polling now runs per-connection via pollConnection() and folds storage-based metrics updates into the same per-connection path (including cleanup on connection removal), while keeping /metrics scrapes calling updateMetrics() for connected connections.

Written by Cursor Bugbot for commit 86e7992. This will update automatically on new commits. Configure here.

Extract common multi-connection polling logic into a reusable abstract
base class. Both HealthService and PrometheusService now extend
MultiConnectionPoller, which provides:

- Standardized polling loop with start/stop lifecycle
- Parallel polling of all connected database instances
- Error isolation between connections
- Automatic cleanup when connections are removed
- Re-entrance guard to prevent overlapping poll cycles

This reduces code duplication and ensures consistent polling behavior
across services while preserving original functionality including the
5-second startup delay for health checks and webhook triggering after
metrics collection.
@BetterDB-inc BetterDB-inc deleted a comment from cursor Bot Feb 3, 2026
@BetterDB-inc BetterDB-inc deleted a comment from cursor Bot Feb 3, 2026
@KIvanow
Copy link
Copy Markdown
Member Author

KIvanow commented Feb 3, 2026

@cursor review

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

Comment thread apps/api/src/health/health.service.ts
@KIvanow KIvanow merged commit 0d1d1e6 into master Feb 4, 2026
2 checks passed
@KIvanow KIvanow deleted the service-polling branch February 4, 2026 10:17
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.

1 participant