feat: add CRDT sync status to health/ready endpoint (#30)#39
Merged
Conversation
Add per-peer sync time tracking to the State struct. The handleMembershipUpdate callback now records the last successful sync time for each peer. New methods CRDTSyncStatus() and IsCRDTSyncHealthy() expose sync lag data and threshold checks. Configurable SyncLagThreshold (default 30s) determines when sync lag makes a node report as not ready. Part of #30 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Register nexus_crdt_sync_lag_seconds and nexus_crdt_peers_connected gauges via promauto. These are updated on every membership update callback from the CRDT layer. Part of #30 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Extend the ReadinessChecker interface with CRDTSyncStatus() and IsCRDTSyncHealthy() methods. The /ready endpoint now returns JSON with crdt_sync details (peers_connected, sync_lag_ms, last_sync). A node reports not-ready if either peer discovery or CRDT sync lag threshold is exceeded. Part of #30 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add state tests for CRDTSyncStatus, IsCRDTSyncHealthy with various peer/threshold scenarios. Add API tests for the ready endpoint with mock readiness checker covering ready, not-ready (discovery), and not-ready (sync lag) cases. Part of #30 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.
Summary
crdt_syncstatus to/readyendpoint response withpeers_connected,sync_lag_ms,last_syncSyncLagThreshold)nexus_crdt_sync_lag_secondsandnexus_crdt_peers_connectedgaugesReady endpoint response format
{ "ready": true, "crdt_sync": { "peers_connected": 2, "sync_lag_ms": 150, "last_sync": "2024-01-01T00:00:00Z" } }Test plan
CRDTSyncStatus()with no peers and with active peersIsCRDTSyncHealthy()within and exceeding threshold/readyendpoint: standalone mode, ready with checker, not-ready (discovery), not-ready (sync lag)go test ./...)Closes #30