Add snapshot support to event sourcing workflow #148
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
SnapshotStoreinterface is defined but snapshots are not integrated into the event sourcing workflow. This means:Current State
EventStoreWithErrorsinevent.go:235- no snapshot methodsSnapshotStoreinterface inevent.go:245- defined but not widely usedJetStreamEventStore.GetLatestSnapshotandSaveSnapshotimplemented but not called automaticallyInMemoryEventStorehas snapshot methods but no lifecycle managementRequired Implementation
1. Snapshot Strategy
Define when to create snapshots:
2. State Capture
Add method to capture actor state:
3. Snapshot Store Extension
Extend
EventStoreWithErrorsto include snapshots:4. Snapshot Workflow
Modify event retrieval to use snapshots:
Suggested Implementation
1. Add CaptureState to EventStore interface
In
event.go, extendEventStoreor createStateStoreinterface:2. Implement CaptureState
In
store/jetstream.go:3. Add Snapshot Helper
Create snapshot utilities:
4. Modify GetEvents
Update
GetEventsin both stores to use snapshots when beneficial.Snapshots Workflow Example
Acceptance Criteria
CaptureStatemethod added to event storeGetEventsuses snapshots to optimize replay