Initial aether repository structure
All checks were successful
CI / build (push) Successful in 1m13s
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>
This commit is contained in:
38
event.go
Normal file
38
event.go
Normal file
@@ -0,0 +1,38 @@
|
||||
package aether
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// Event represents a domain event in the system
|
||||
type Event struct {
|
||||
ID string `json:"id"`
|
||||
EventType string `json:"eventType"`
|
||||
ActorID string `json:"actorId"`
|
||||
CommandID string `json:"commandId,omitempty"` // Correlation ID for command that triggered this event
|
||||
Version int64 `json:"version"`
|
||||
Data map[string]interface{} `json:"data"`
|
||||
Timestamp time.Time `json:"timestamp"`
|
||||
}
|
||||
|
||||
// ActorSnapshot represents a point-in-time state snapshot
|
||||
type ActorSnapshot struct {
|
||||
ActorID string `json:"actorId"`
|
||||
Version int64 `json:"version"`
|
||||
State map[string]interface{} `json:"state"`
|
||||
Timestamp time.Time `json:"timestamp"`
|
||||
}
|
||||
|
||||
// EventStore defines the interface for event persistence
|
||||
type EventStore interface {
|
||||
SaveEvent(event *Event) error
|
||||
GetEvents(actorID string, fromVersion int64) ([]*Event, error)
|
||||
GetLatestVersion(actorID string) (int64, error)
|
||||
}
|
||||
|
||||
// SnapshotStore extends EventStore with snapshot capabilities
|
||||
type SnapshotStore interface {
|
||||
EventStore
|
||||
GetLatestSnapshot(actorID string) (*ActorSnapshot, error)
|
||||
SaveSnapshot(snapshot *ActorSnapshot) error
|
||||
}
|
||||
Reference in New Issue
Block a user