Comments (4)
Yup, that is the method I was talking of - it switches the argument order from the @singledispatch
- which needs F(event:E, state:S) -> S
to F'(state:S, event:E) -> S
, which is needed by reduce
. This took me a bit of time to catch, as its a rather subtle difference when you're just reading through the code.
I added some comments to PR #60 , I like the refactors: it feels cleaner.
Looking forward to the next release.
from eventsourcing.
Actually, you need to use the classmethod on the repository, which has the call order reversed so it works with reduce, and sets up the class if the initial state is None. Wasn't clear to me initially. should document this.
from eventsourcing.
On the develop branch, the ExampleApplication
enables snapshotting by constructing a snapshot strategy, then passing it to the event sourced repository. That causes the repository to check for a snapshot before it gets all the events. And if there is a snapshot, it only gets the events that were applied after the snapshot was taken. It also uses older snapshots when getting an entity at a historical version. There's a test covering it.
self.example_repo = ExampleRepository(
event_store=self.version_entity_event_store,
snapshot_strategy=self.snapshot_strategy,
)
However, I had two issues with this code: firstly snapshots used timestamps not version numbers, and also there wasn't a snapshotting policy to automatically create snapshots.
So I just reworked the snapshotting. The snapshot records are now in a dedicated table. Snapshots use integers which correspond to event entity version attribute, rather than event timestamps. I added a section to the README file about using snapshots (will move it to the new docs when the code snippets in the new docs are covered with a test, with something like the test_readme.py). And in that new section added an example snapshotting policy that automatically takes a snapshot every five events.
The changes are in PR #60. Let me know what you think?
(Not sure which class method you meant, was it mutate()? I think it's correct that the snapshot events aren't supported by the mutator function, if that's what was happening in your first comment.)
from eventsourcing.
Just to link things up, there is now a page in the documentation about snapshotting, here:
http://eventsourcing.readthedocs.io/en/latest/topics/user_guide/snapshotting.html
from eventsourcing.
Related Issues (20)
- Question: Any intention to extend/fork this library to async? HOT 7
- Postgres does not accept idle_in_transaction_session_timeout as float string HOT 2
- Postgres schema change possibility HOT 5
- Investigating potential problem when saving events for multiple aggregates HOT 2
- Custom Postgres schema breaks followers HOT 3
- Aggregate Not Found when AGGREGATE_CACHE_MAXSIZE not set HOT 13
- monotonic HOT 2
- support postgresql as alias for postgres persistence module HOT 3
- Support for rabbitmq HOT 10
- Best way to befriend sqlalchemy database and eventsourcing HOT 6
- Is it necessary to re-hydrate an aggregate to check it exists in a repository? HOT 4
- Suggested approach to Entities in 9.x? HOT 1
- Slack invite not working HOT 3
- Snapshot in aggregate8 example won't work for custom object in aggregate HOT 8
- `Follower(Application)` does not call `self.construct_mapper()` HOT 5
- Additional examples HOT 2
- How to set aggregate/application state for tests? HOT 1
- Automatic snapshotting not work for functional style aggregate HOT 8
- Use ProcessApplication build materialized view HOT 2
- Question: How to best integrate with token based authentication for Postgres HOT 16
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from eventsourcing.