Package: meepo
Meepo is event sourcing and event broadcasting for databases.Documentation:https://meepo.readthedocs.org/InstallationInstall with pip$pipinstallmeepoTo use mysql binlog as event source, install additional requires with$pipinstallmeepo[mysqlbinlog]FeaturesMeepo can publish the table events from database to the outside, so it can
be  used to do a lot of interesting things, including:cache invalidationreplication to RDBS / NoSQL / SearchEngineevent sourcinglogging and auditingrealtime analyticsnotifications pushingIntromeepois event sourcing and event broadcasting for databases, it follows
database table events fromsqlalchemyandmysql binlog, and publish
them to subscribers.MySQL Pubmysql_pubevent 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_pubgenerates an accurate event stream with one
pk per event.For example, the  following sql:INSERTINTOtest(data)VALUES('a');INSERTINTOtest(data)VALUES('b'),('c'),('d');UPDATEtestSETdata='aa'WHEREid=1;UPDATEtestSETdata='bb'WHEREid=2;UPDATEtestSETdata='cc'WHEREid!=1;DELETEFROMtestWHEREid!=1;DELETEFROMtestWHEREid=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 1SQLAlchemy Pubsqlalchemy_pubevent 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 |
                         +-----------------------+         |                     |
                                                           +---------------------+SQLAlchemyis a ORM layer above database, it usessessionto maintain
model instances states before the data flush to database, and flush them to
database in commit.Someepowill hook into the event system, record all the instances insession.new,session.dirty,session.deletedinbefore_flushevent,
then publish the table_action event after commit issued.For example, the  following code:classTest(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 3ExamplesRefer tomeepo/examples/for more examples.ContributeFork 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.