[PIP] Event stream
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 9.9k
- Forks
- 735
- Avg merge
- 6h 36m
- Merged PRs (30d)
- 8
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Read the proposed DatabaseConnection, Inserter, Updater, and Deleter architecture first; no files or tests are named. Before implementation, resolve the broadcast-channel choice, event semantics, custom SQL and processor behavior, and the DatabaseConnection breaking change, with completion defined by an agreed proposal.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust, sql
- Domain
- databases
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100