-
-
Notifications
You must be signed in to change notification settings - Fork 653
Description
No pun intended, PIP stands for "Proposal & Implementation Plan".
Motivation
To generate a high level event stream of changes to Entities, and serve as a foundation to change capture and other event-based system paradigm.
Architecture
When this flag is enabled, DatabaseConnection will maintain a broadcast channel (is there non-tokio equivalent?) internally, and users will be able to subscribe to this channel (via subscribe(&self) -> Receiver<Event>.
If execution succeeded, Inserter, Updater & Deleter will extract some semantic information from the query and generate an Event, and push to the channel.
Information we can extract and represent:
- New Model: the newly inserted ID and content of the new Model
- Update Model: ID of the model, which fields are changed and the updated values
- Delete Model: ID of the deleted model, and perhaps content of the deleted Model
Notes 1: We should not buffer events. When no one is subscribing, we will discard all events.
Notes 2: I imagine a subscriber can persist these event, may be even saving to the same database. To prevent infinite echo, we should have an option to ignore certain tables.
Breaking changes
It seems that we need to convert DatabaseConnection from a enum to a struct.
Open questions
- How to allow custom SQL execution to generate events
- How to allow custom processors to handle
InsertStatementandUpdateStatement