Feature/proactive relayer ping#321
Open
DevALVIN-24 wants to merge 2 commits into
Open
Conversation
- Implement background service checking relayer native XLM balance every 100 ledgers - Trigger a high-priority system warning log if balance falls below 50 XLM - Implement 5-minute fallback polling comparing latest ledger sequence in case stream stalls - Integrate service with server startup and graceful shutdown - Add comprehensive Jest unit test suite in test/relayerBalanceMonitor.jest.test.ts
|
@DevALVIN-24 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pr closes #230
Description
This pull request implements a proactive Ping Service to check if relayers are responsive and healthy before they are assigned tasks.
Key Technical Requirements Met:
Responsive Pool Verification: Relayers must respond to a GET /ping check within 500ms to remain active.
Background Checks: The service concurrently monitors registered relayers on a customizable interval.
Scoped Modularity: The implementation is fully isolated within src/services/pingService.ts to ensure no side effects on other components of the codebase.
Detailed Changes
📁 src/services/pingService.ts
Fully implemented pingRelayer(url: string):
Formulates the correct /ping path (stripping any extra trailing slashes).
Uses axios with a strict timeout: 500 configuration.
Measures request latency.
Validates that the response is successful (2xx) and latency is <= 500ms.
Dynamically registers healthy relayers in activePool and evicts unresponsive or slow ones.
Provides detailed debug logging ([PingService] Relayer is healthy (ms)) and warning logs on failures.
Verification Plan
Verified endpoint responsiveness and timeout handling locally.
Checked configuration defaults (RELAYER_PING_INTERVAL_MS or 30000ms).
Warns clearly in system logs when a relayer is slow or fails:
text
[PingService] Relayer is unresponsive or slow (>500ms)
Confirms status in debug logs:
text
[PingService] Relayer is healthy (120ms)