[Issue #35] Add mutex protection to ConsistentHashRing for thread safety #40

Merged
HugoNijhuis merged 1 commits from issue-35-hashring-mutex into main 2026-01-10 17:47:53 +00:00

1 Commits

Author SHA1 Message Date
4666bb6503 Add mutex protection to ConsistentHashRing for thread safety
All checks were successful
CI / build (pull_request) Successful in 16s
- Add sync.RWMutex to ConsistentHashRing struct
- Use Lock/Unlock for write operations (AddNode, RemoveNode)
- Use RLock/RUnlock for read operations (GetNode, GetNodes, IsEmpty)

This allows concurrent reads (the common case) while serializing writes,
preventing race conditions when multiple goroutines access the hash ring.

Closes #35

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-10 18:46:38 +01:00