Installation
Why eGo
GoAkt provides the actor runtime — messaging, supervision, clustering, streams. eGo builds on that runtime to solve the persistence and workflow layer:Core behaviors
eGo offers two persistence models. Choose based on whether you need a full event history or just the latest state.Event-sourced behavior
EventSourcedBehavior captures state changes as domain events. Commands are processed sequentially — each command produces zero or more events that are persisted to a journal. State is rebuilt by replaying events on recovery.
Additional capabilities:
Durable-state behavior
DurableStateBehavior persists only the latest state — no event log, no replay. Each successful command produces a new state version, and only the latest version is stored.
This model is a good fit for configuration-style entities, lower-overhead persistence needs, and use cases where audit replay is not required.
Choosing a model
Persistence stores
eGo uses pluggable store interfaces. In-memory stores ship for testing; production backends are in the ego-contrib repository.
Implement any interface to plug in your own backend.
Engine
The eGoEngine manages entity lifecycle, wires persistence, and optionally enables clustering. Create an engine with ego.NewEngine(name, eventStore, options...), then call Start and Stop to manage its lifecycle.
Entity spawn options
Clustering
eGo delegates clustering to GoAkt. UseWithCluster to distribute entities across nodes. Entities are partitioned by identity and placed on nodes transparently. Commands are routed by the framework.
Event batching
Under concurrent load, individual store writes become a throughput bottleneck. Event batching accumulates events across commands and flushes in a single write. While a batch is written, incoming commands are stashed and replayed after the write completes. A threshold of0 (default) disables batching.
Projections
Projections consume persisted events and build read models. They track progress via an offset store and support retry, dead-letter handling, and rebuild.Event publishing
eGo provides publisher APIs for pushing domain changes to external systems.Sagas
Sagas coordinate long-running workflows across multiple entities with compensation for failures. Saga state is persisted using the same event-sourced foundations. Start a saga withEngine.Saga() and inspect it with Engine.SagaStatus(). Define compensation logic for timeouts and failures within your saga behavior.
Event adapters
Event adapters transform persisted events during replay and projection consumption, enabling schema evolution without data migration. Register transforms via theeventadapter package.
Encryption
eGo supports at-rest encryption of events and snapshots for GDPR and compliance requirements. Enable withWithEncryption(encryptor) on the engine. Use Engine.EraseEntity(entityID) for GDPR-style data erasure.
Observability
When configured withWithTelemetry(), eGo emits OpenTelemetry traces and metrics:
Testkit
eGo ships a scenario-based testkit for validating behaviors without a running store. Usetestkit.New for event-sourced and testkit.NewDurableState for durable-state behaviors with a Given/When/Then API.
See also
- eGo repository — Source code, examples, and changelog
- ego-contrib — Postgres and MongoDB store implementations
- Extensions and Dependencies — GoAkt extension mechanism that eGo builds on
- PubSub — Application-level topic-based messaging
- Coordinated Shutdown — Graceful shutdown that eGo entities participate in