feat: Node.js CircuitBreaker with exponential OPEN cooldown — GH#4775#4793
feat: Node.js CircuitBreaker with exponential OPEN cooldown — GH#4775#4793balhar-jakub wants to merge 13 commits into
Conversation
Create standalone CircuitBreaker.js with CLOSED/OPEN/HALF_OPEN states, exponential backoff capped at 300s, and EventEmitter-based state events. Comprehensive unit tests (40 cases) cover all state transitions, cooldown timing, backoff computation, edge cases, and lifecycle. Part of #4775 (Area A) Signed-off-by: Jakub Balhar <jakub.balhar@broadcom.com>
…ry fetch scheduling - Add circuitBreaker config block to defaultConfig.js (enabled, maxFailures=5, cooldownTime=60000, backoffMax=300000) - Import CircuitBreaker and instantiate in EurekaClient constructor with event-driven logging (WARN for OPEN, INFO for CLOSE/HALF_OPEN) - Rewrite startHeartbeats() and startRegistryFetches() to use setTimeout-based scheduling with circuit breaker gating via allowRequest() - On success: call recordSuccess(); on failure: call recordFailure() with backoff-driven rescheduling - Add optional callback parameter to renew() for success/failure notification - Rewrite stop() to cancel pending setTimeout handles - Fall back to legacy setInterval when circuitBreaker.enabled=false - Add 11 integration tests (AC1-AC9 + disabled fallback + registry fetch gate) - Fix pre-existing lint issues in index.js and CircuitBreaker.test.js Refs: #4775 Signed-off-by: Jakub Balhar <jakub.balhar@broadcom.com>
Signed-off-by: Jakub Balhar <jakub.balhar@broadcom.com>
- Rework CircuitBreaker for exponential OPEN cooldown per AC5+AC6 - Remove baseCooldown; use cooldownTime as sole base for all backoff - Track _openCycleCount for OPEN cooldown doubling (capped at backoffMax) - HALF_OPEN→CLOSED resets _openCycleCount - 49 unit tests covering construction, states, events, lifecycle, edge cases - EPL-2.0 license only (remove Apache/MIT from prior art) Signed-off-by: Jakub Balhar <jakub.balhar@broadcom.com>
- Remove Apache 2.0 and MIT license headers from prior art - Keep only EPL-2.0 license as required by project Signed-off-by: Jakub Balhar <jakub.balhar@broadcom.com>
- Update EurekaClient integration tests for cooldownTime-based exponential backoff - AC2-AC8 tests updated: timings now use cooldownTime * 2^(N-1) instead of baseCooldown - EPL-2.0 license only (remove Apache/MIT from prior art) - CircuitBreaker constructor already compatible (no baseCooldown passed) Signed-off-by: Jakub Balhar <jakub.balhar@broadcom.com>
QA + Security Review — PR #4793 (Closes #4775)Verdict: ✅ APPROVED (pending CI)Architecture ValidationImplementation matches the architect's solution design exactly:
Pavel's Lens — All 8 Rules
Codebase Grep Results
Build & Tests
Minor Observations (non-blocking)
|
Signed-off-by: Jakub Balhar <jakub.balhar@broadcom.com>
CI Status Update — PR #4793BuildAndTest FAILURE: Pre-existing CI infrastructure issue (NOT caused by this PR)The BuildAndTest CI check fails at Root cause: The CI runner's Node.js version (v24.10.0) is older than the engine requirement in Impact: ANY PR against No changes to package.json or package-lock.json were made in this PR (verified: InfinispanJGroupStabilityTest: Cancelled (transient GitHub Actions issue)This job was cancelled before running any steps. Unrelated to Node.js changes. All other checks: ✅ PASS
|
tapheret2
left a comment
There was a problem hiding this comment.
Review pass
Static review of the open diff:
- Looks focused enough for a community review pass
- Please ensure tests/docs match any behavior change
- Call out breaking changes in the PR body if any
Thanks — re-submitted after rate-limit cooldown.
Return full licenses as required for Enabler Signed-off-by: Jakub Balhar <jakub@balhar.net>
Signed-off-by: Jakub Balhar <jakub@balhar.net>
Signed-off-by: Jakub Balhar <jakub@balhar.net>
Signed-off-by: Jakub Balhar <jakub@balhar.net>
Signed-off-by: Jakub Balhar <jakub@balhar.net>
|



Closes #4775
Adds a CircuitBreaker state machine to the Node.js onboarding enabler EurekaClient with exponential OPEN cooldown.
Changes