core: cluster with distributed in-memory backend (experimental)#46
core: cluster with distributed in-memory backend (experimental)#46
Conversation
|
Running Code Quality on PRs by uploading data to Trunk will soon be removed. You can still run checks on your PRs using trunk-action - see the migration guide for more information. |
There was a problem hiding this comment.
Pull Request Overview
This PR introduces a new experimental distributed in-memory backend (DistMemory) that simulates a multi-node cluster within a single process using consistent hashing, replication, and failure detection mechanisms. The implementation includes comprehensive distributed system features like consistent hash rings, membership management, heartbeat-based failure detection, read repair, and versioning.
- Adds a complete distributed backend with consistent hashing, replication, and cluster membership
- Updates the
TriggerEvictionmethod signature to accept a context parameter across all middleware layers - Introduces new management HTTP endpoints for distributed cluster introspection and diagnostics
Reviewed Changes
Copilot reviewed 31 out of 31 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/backend/dist_memory.go | Core distributed memory backend implementation with consistent hashing, replication, and failure detection |
| internal/cluster/*.go | Cluster primitives for node identity, membership tracking, and consistent hash ring |
| tests/*.go | Comprehensive test suite covering distributed operations, versioning, heartbeat, and cluster management |
| service.go, pkg/middleware/*.go | Updates TriggerEviction method signature to accept context parameter |
| management_http.go | Adds new distributed cluster introspection endpoints |
| hypercache.go | Integrates DistMemory backend and adds distributed introspection methods |
Comments suppressed due to low confidence (1)
pkg/backend/dist_memory.go:126
- The nolint directive is incorrectly placed for a function that doesn't return anything. The
ireturnlinter checks for interface returns, but this function has no return value.
}
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| } | ||
|
|
||
| // repairRemoteReplica updates a remote replica if stale (best-effort). | ||
| func (dm *DistMemory) repairRemoteReplica(ctx context.Context, key string, chosen *cache.Item, oid cluster.NodeID) { // separated to reduce cyclomatic complexity //nolint:ireturn |
There was a problem hiding this comment.
The nolint directive is incorrectly placed for a function that doesn't return anything. The ireturn linter checks for interface returns, but this function has no return value.
| func (dm *DistMemory) repairRemoteReplica(ctx context.Context, key string, chosen *cache.Item, oid cluster.NodeID) { // separated to reduce cyclomatic complexity //nolint:ireturn | |
| func (dm *DistMemory) repairRemoteReplica(ctx context.Context, key string, chosen *cache.Item, oid cluster.NodeID) { // separated to reduce cyclomatic complexity |
| } | ||
|
|
||
| // runHeartbeatTick runs one heartbeat iteration (best-effort). | ||
| func (dm *DistMemory) runHeartbeatTick(ctx context.Context) { //nolint:ireturn |
There was a problem hiding this comment.
The nolint directive is incorrectly placed for a function that doesn't return anything. The ireturn linter checks for interface returns, but this function has no return value.
| func (dm *DistMemory) runHeartbeatTick(ctx context.Context) { //nolint:ireturn | |
| func (dm *DistMemory) runHeartbeatTick(ctx context.Context) { |
| } | ||
|
|
||
| // evaluateLiveness applies timeout-based transitions then performs a probe. | ||
| func (dm *DistMemory) evaluateLiveness(ctx context.Context, now time.Time, node *cluster.Node) { //nolint:ireturn |
There was a problem hiding this comment.
The nolint directive is incorrectly placed for a function that doesn't return anything. The ireturn linter checks for interface returns, but this function has no return value.
| func (dm *DistMemory) evaluateLiveness(ctx context.Context, now time.Time, node *cluster.Node) { //nolint:ireturn | |
| func (dm *DistMemory) evaluateLiveness(ctx context.Context, now time.Time, node *cluster.Node) { |
| } | ||
|
|
||
| // repairReplicas ensures each owner has at least the chosen version; best-effort. | ||
| func (dm *DistMemory) repairReplicas(ctx context.Context, key string, chosen *cache.Item, owners []cluster.NodeID) { //nolint:ireturn |
There was a problem hiding this comment.
The nolint directive is incorrectly placed for a function that doesn't return anything. The ireturn linter checks for interface returns, but this function has no return value.
| func (dm *DistMemory) repairReplicas(ctx context.Context, key string, chosen *cache.Item, owners []cluster.NodeID) { //nolint:ireturn | |
| func (dm *DistMemory) repairReplicas(ctx context.Context, key string, chosen *cache.Item, owners []cluster.NodeID) { |
No description provided.