Skip to content

core: cluster with distributed in-memory backend (experimental)#46

Merged
hyp3rd merged 3 commits intomainfrom
feat/distributed-backend
Aug 22, 2025
Merged

core: cluster with distributed in-memory backend (experimental)#46
hyp3rd merged 3 commits intomainfrom
feat/distributed-backend

Conversation

@hyp3rd
Copy link
Owner

@hyp3rd hyp3rd commented Aug 22, 2025

No description provided.

Copilot AI review requested due to automatic review settings August 22, 2025 16:04
@trunk-io
Copy link

trunk-io bot commented Aug 22, 2025

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.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 TriggerEviction method 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 ireturn linter 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
Copy link

Copilot AI Aug 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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

Copilot uses AI. Check for mistakes.
}

// runHeartbeatTick runs one heartbeat iteration (best-effort).
func (dm *DistMemory) runHeartbeatTick(ctx context.Context) { //nolint:ireturn
Copy link

Copilot AI Aug 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
func (dm *DistMemory) runHeartbeatTick(ctx context.Context) { //nolint:ireturn
func (dm *DistMemory) runHeartbeatTick(ctx context.Context) {

Copilot uses AI. Check for mistakes.
}

// evaluateLiveness applies timeout-based transitions then performs a probe.
func (dm *DistMemory) evaluateLiveness(ctx context.Context, now time.Time, node *cluster.Node) { //nolint:ireturn
Copy link

Copilot AI Aug 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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) {

Copilot uses AI. Check for mistakes.
}

// 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
Copy link

Copilot AI Aug 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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) {

Copilot uses AI. Check for mistakes.
@hyp3rd hyp3rd merged commit 3769f53 into main Aug 22, 2025
3 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant