Files
aether/cluster/cluster.go
Hugo Nijhuis c757bb76f3
All checks were successful
CI / build (pull_request) Successful in 16s
CI / build (push) Successful in 15s
Make configuration values injectable rather than hardcoded
Add config structs with sensible defaults for tunable parameters:
- JetStreamConfig for stream retention (1 year) and replica count (1)
- HashRingConfig for virtual nodes per physical node (150)
- ShardConfig for shard count (1024) and replication factor (1)

Each component gets a new WithConfig constructor that accepts custom
configuration, while the original constructors continue to work with
defaults. Zero values in configs fall back to defaults for backward
compatibility.

Closes #38

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-10 15:33:56 +01:00

48 lines
1.8 KiB
Go

// Package cluster provides distributed computing capabilities for the Aether VM runtime.
//
// This package implements a distributed actor system using NATS for coordination,
// featuring consistent hashing for shard distribution, leader election for
// coordination, and fault-tolerant actor migration between nodes.
//
// Key Components:
//
// - ConsistentHashRing: Distributes actors across cluster nodes using consistent hashing
// - LeaderElection: NATS-based leader election with lease-based coordination
// - ClusterManager: Coordinates distributed operations and shard rebalancing
// - NodeDiscovery: Manages cluster membership and node health monitoring
// - ShardManager: Handles actor placement and distribution across shards
// - DistributedVM: Main entry point for distributed VM cluster operations
//
// Usage:
//
// // Create a distributed VM node
// distributedVM, err := cluster.NewDistributedVM("node-1", []string{"nats://localhost:4222"}, localRuntime)
// if err != nil {
// log.Fatal(err)
// }
//
// // Start the cluster node
// if err := distributedVM.Start(); err != nil {
// log.Fatal(err)
// }
//
// // Load a model across the cluster
// if err := distributedVM.LoadModel(eventStormingModel); err != nil {
// log.Fatal(err)
// }
//
// Architecture:
//
// The cluster package implements a distributed actor system where each node
// runs a local VM runtime and coordinates with other nodes through NATS.
// Actors are sharded across nodes using consistent hashing, and the system
// supports dynamic rebalancing when nodes join or leave the cluster.
//
// Fault Tolerance:
//
// - Automatic node failure detection through heartbeat monitoring
// - Leader election ensures coordination continues despite node failures
// - Actor migration allows rebalancing when cluster topology changes
// - Graceful shutdown with proper resource cleanup
package cluster