All checks were successful
CI / build (push) Successful in 1m13s
Distributed actor system with event sourcing for Go: - event.go - Event, ActorSnapshot, EventStore interface - eventbus.go - EventBus, EventBroadcaster for pub/sub - nats_eventbus.go - NATS-backed cross-node event broadcasting - store/ - InMemoryEventStore (testing), JetStreamEventStore (production) - cluster/ - Node discovery, leader election, shard distribution - model/ - EventStorming model types Extracted from arcadia as open-source infrastructure component. Co-Authored-By: Claude <noreply@anthropic.com>
48 lines
1.8 KiB
Go
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 |