Repository navigation
Description
Context
The AnnounceKey and QueryKeyOwnership methods on DistributedCoordinator (added as stubs in A1-2) need real implementations. These are the foundation of peer-to-peer cache warming: nodes announce when they cache an object, and other nodes query ownership before going to S3.
What to implement
In internal/distributed/coordinator.go (or a new cache_announce.go):
Add to Coordinator:
announcements map[string][]types.KeyAnnouncement // key → list of holders
announcementsMu sync.RWMutexImplement AnnounceKey(ctx, ann types.KeyAnnouncement) error:
- Store announcement in local
announcementsmap (append/replace by NodeID) - Broadcast a
MessageTypeCacheAnnouncegossip message to all alive peers - Start a background TTL eviction goroutine (default 5 minutes) if not already running
Add recordAnnouncement(ann types.KeyAnnouncement) as the internal method called both locally and by the gossip handler.
Implement QueryKeyOwnership(ctx, key string) ([]types.KeyAnnouncement, error):
- Acquire
announcementsMu.RLock() - Return a copy of
announcements[key](empty slice, not nil, if not found)
In internal/distributed/gossip.go:
Add MessageTypeCacheAnnounce MessageType = "cache_announce" to the message type constants. Handle it in handleIncomingMessage by calling gp.cluster.coordinator.(*Coordinator).recordAnnouncement(ann).
Acceptance criteria
AnnounceKeybroadcasts to peers and stores locallyQueryKeyOwnershipreturns local announcements (no network call — local map only)- TTL eviction removes stale announcements after 5 minutes (configurable)
- Goroutine safety:
go test -race ./internal/distributed/...passes - Integration test: node A calls
AnnounceKey, node B (connected via loopback UDP) callsQueryKeyOwnershipfor same key, gets node A's entry
Sequencing
Depends on A1-2 (interface) and A2-1 (coordinator wired into FUSE). Must land before A2-3 and A2-4.
Activity
feat(types)!: cache coordination on DistributedCoordinator, with stub…
feat(cluster): make cluster.enabled actually start cluster coordinati…
feat(cluster): peers learn which keys are cached elsewhere (#140) (#402)
feat(cluster): a write on one node evicts what its peers cached (#141) (