johanhaleby / occurrent

Unintrusive Event Sourcing Library for the JVM
https://occurrent.org
125 stars 16 forks source link

Support automatic snapshots #112

Open johanhaleby opened 2 years ago

johanhaleby commented 2 years ago

Vanligt:

SnapshotStore i ApplicationService

newEventsSinceLastSnapShot.foldLeft(previousSnapshotState, .. ) => newSnapshotState
Snapshot {

    version: 1
    streamName:
    streamVersion:
    payload: {

    }
}
johanhaleby commented 2 years ago

introduce:

SnapshottingApplicationService {
   fun execute(streamId, fn: (State, List<Event>) -> List<Event>)
}

GenericApplicationService can then impl both SnapshottingApplicationService and ApplicationService.