Meepo is event sourcing and event broadcasting for databases.
Documentation: https://meepo.readthedocs.org/
Installation
Install with pip
$ pip install meepo
To use mysql binlog as event source, install additional requires with
$ pip install meepo[mysqlbinlog]
Features
Meepo can publish the table events from database to the outside, so it can be used to do a lot of interesting things, including:
cache invalidation
replication to RDBS / NoSQL / SearchEngine
event sourcing
logging and auditing
realtime analytics
notifications pushing
Intro
meepo is event sourcing and event broadcasting for databases, it follows database table events from sqlalchemy and mysql binlog, and publish them to subscribers.
MySQL Pub
mysql_pub event flow:
+---------------------+
| |
+---> table_write event |
| | |
| +---------------------+
|
+--------------------+ +---------------+ |
| | | | | +---------------------+
| mysql | | meepo.pub | | | |
| +------> +--+---> table_update event |
| row-based binlog | | mysql_pub | | | |
| | | | | +---------------------+
+--------------------+ +---------------+ |
|
| +---------------------+
| | |
+---> table_delete event |
| |
+---------------------+
MySQL Pub use row-based mysql binlog as events source, and transfer them into table_action events. mysql_pub generates an accurate event stream with one pk per event.
For example, the following sql:
INSERT INTO test (data) VALUES ('a');
INSERT INTO test (data) VALUES ('b'), ('c'), ('d');
UPDATE test SET data = 'aa' WHERE id = 1;
UPDATE test SET data = 'bb' WHERE id = 2;
UPDATE test SET data = 'cc' WHERE id != 1;
DELETE FROM test WHERE id != 1;
DELETE FROM test WHERE id = 1;
Generates the following events:
test_write 1 test_write 2 test_write 3 test_write 4 test_update 1 test_update 2 test_update 2 test_update 3 test_update 4 test_delete 2 test_delete 3 test_delete 4 test_delete 1
SQLAlchemy Pub
sqlalchemy_pub event flow:
+------------------+
| |
| meepo.pub |
| |
| sqlalchemy_pub | +---------------------+
| | +-----------------------+ | |
+---------+--------+ | | +---> table_write event |
| | before_flush | | | |
hook | +--> | | +---------------------+
| | | record model states | |
+---------v--------+ | | | |
| | | +-----------+-----------+ | +---------------------+
| sqlalchemy | | | | | |
| +--+ | +------> table_update event |
| session events | | | | | |
| | +-----------v-----------+ | | +---------------------+
+------------------+ | | | |
| after_commit | | |
| +--+ | +---------------------+
| record model states | | | |
| | +---> table_delete event |
+-----------------------+ | |
+---------------------+
SQLAlchemy is a ORM layer above database, it uses session to maintain model instances states before the data flush to database, and flush them to database in commit.
So meepo will hook into the event system, record all the instances in session.new, session.dirty, session.deleted in before_flush event, then publish the table_action event after commit issued.
For example, the following code:
class Test(Base):
__tablename__ = "test"
id = Column(Integer, primary_key=True)
data = Column(String)
t_1 = Test(id=1, data='a')
session.add(t_1)
session.commit()
t_2 = Test(id=2, data='b')
t_3 = Test(id=3, data='c')
session.add(t_2)
session.add(t_3)
session.add(t_4)
session.commit()
t_2.data = "x"
session.commit()
session.delete(t_3)
session.commit()
Generates the following events:
test_write 1 test_write 2 test_write 3 test_update 2 test_delete 3
Examples
Refer to meepo/examples/ for more examples.
Contribute
Fork the repo and make changes.
Write a test which shows a bug was fixed or the feature works as expected.
Make sure travis-ci test succeed.
Send pull request.
Metadata
Release files for meepo 0.1.9
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| meepo-0.1.9.tar.gz | 13.6 kB | Without provenance | Details |
Release files / meepo-0.1.9.tar.gz
| Download URL | meepo-0.1.9.tar.gz |
|---|---|
| Size | 13.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fae12e791a4e6ff7d2da4bbad1ca7076273de4e2eecb89ad2d05c3985482dba3
|
|
BLAKE2b-256 checksum How to use checksums |
e8c35a9f7fe60612808e8ea5013661083f6afd1b8c00863454da23254fd05166
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for meepo 0.1.9
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.