feat: implement heartbeat service for marketplace presence with exponential backoff#35
Merged
shubham3121 merged 3 commits intomainfrom Jan 28, 2026
Merged
Conversation
- Add HeartbeatManager service for sending periodic heartbeats to SyftHub - Implement adaptive interval algorithm (15s → 600s max, 2x backoff) - Reset to aggressive retry (15s) on failure for quick recovery - Use TTL = 3x interval to tolerate missed heartbeats - Add 10-15% jitter using secrets.SystemRandom to prevent thundering herd - Wait for proxy connection before starting heartbeat cycle
…lic URL - Replace proxy service with settings repository in HeartbeatManager for public URL management. - Introduce method to retrieve public URL from settings. - Adjust heartbeat loop to wait for public URL instead of proxy connection. - Implement logic to handle public URL removal and prune stale marketplace states.
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 pull request introduces a robust heartbeat manager to the backend, enabling Syft Space to periodically send presence heartbeats to registered SyftHub marketplaces. The heartbeat system includes adaptive backoff, jitter, failure handling, and multi-marketplace support. Additionally, configuration options and supporting API changes are introduced to facilitate this feature.
Heartbeat Manager Integration:
HeartbeatManagerservice that sends periodic heartbeats to all active marketplaces, featuring adaptive interval management, exponential backoff, jitter, and failure recovery. This service is integrated into the FastAPI application lifecycle and can be enabled or disabled via configuration. [1] [2] [3] [4]Supporting API and Repository Changes:
SettingsRepositorywith aget_public_urlmethod, allowing the heartbeat manager to retrieve the current public URL dynamically.AppSettings) to include aheartbeat_enabledflag, allowing deployment-time control over the heartbeat feature.SyftHub Client Enhancements:
send_heartbeatmethod toSyftHubClientfor posting heartbeat data to SyftHub, along with a correspondingHeartbeatResponsemodel for parsing responses. Also introduced a default TTL constant for heartbeat messages. [1] [2] [3]Application Initialization and Lifecycle:
HeartbeatManageras part of the FastAPI app's startup and shutdown sequence, ensuring it starts after other core services and receives the current tenant ID. [1] [2]These changes collectively enable Syft Space to reliably advertise its presence to SyftHub marketplaces, improving connectivity, monitoring, and operational resilience.