Skip to content

Commit

Permalink
Merge pull request #1 from moleculer-go/feat/snapshot
Browse files Browse the repository at this point in the history
Feat/snapshot
  • Loading branch information
pentateu committed Oct 12, 2019
2 parents 2714ac7 + 77b8918 commit d929ace
Show file tree
Hide file tree
Showing 17 changed files with 1,347 additions and 310 deletions.
3 changes: 2 additions & 1 deletion .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ steps:
COVERALLS_TOKEN:
from_secret: COVERALLS_TOKEN
commands:
- go run github.com/onsi/ginkgo/ginkgo -r --keepGoing --cover --trace
- go version
- go run github.com/onsi/ginkgo/ginkgo -r --cover --trace
- go run github.com/modocache/gover ./ coverage.txt
- curl -s https://codecov.io/bash | bash || echo "Failed to upload to codecov.io!"
- go run github.com/mattn/goveralls -coverprofile=coverage.txt -service=drone.io || echo "Failed to upload to coverrals!"
32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,34 @@
# cqrs
CQRS Pluggin and components


## Snapshots

snapshotName := aggregate.snapshot():
- pause event pumps -> pause aggregate changes :)
- create a snapshot event -> new events will pile up after this point! = Write is enabled.
- ** no changes are happening on aggregates ** but reads continue happily.
- backup aggregates -> aggregate.backup(snapshotName) (SQLLite -> basicaly copy files :) )
- restart the event pump :)
- done.
- Error scenarios:
- if backup fails the event is marked as failed and is ignored when trying to restore events.
- Rationale:
---> Since you created an event about the start of the snapshot at the same moment you paused the pump. this event should point to the backup file. so it can be used when restoring the snapshot.


The restore an snapshot is also very simple
aggregate.restore(snapshotName)
- Condition: event pump is paused.
- find backup files using snapshotName and locate snapshot event in the event store.
- ** at this stage the event store might be receiving new events -> write is enabled **
- backup is restored.
- read is enabled :)
- events start processing from the snapshot moment
- ** system takes a while to catch up **
- system is eventually consistent :)


## Event Store

Write test cases for the lifecyc;e variable "dispatchEventsStopped"

0 comments on commit d929ace

Please sign in to comment.