예제 #1
0
파일: mprint.py 프로젝트: amumu/meepo
def main(mysql_dsn, tables, blocking=False, debug=False):
    level = "DEBUG" if debug else "INFO"
    setup_logger(level)
    print_sub(tables)

    pub_tables = tables if tables else None
    mysql_pub(mysql_dsn, tables=pub_tables, blocking=blocking)
예제 #2
0
def main(mysql_dsn, tables, blocking=False, debug=False):
    level = "DEBUG" if debug else "INFO"
    setup_logger(level)
    print_sub(tables)

    pub_tables = tables if tables else None
    mysql_pub(mysql_dsn, tables=pub_tables, blocking=blocking)
예제 #3
0
파일: mzmq.py 프로젝트: thienkimlove/meepo
def main(bind, master_dsn, tables, blocking=False):
    setup_logger("INFO")

    logger = logging.getLogger(__name__)

    # currently only supports mysql master
    assert master_dsn and master_dsn.startswith("mysql")
    assert bind.startswith("ipc") or bind.startswith("tcp")

    logger.info("event sourcing tables: %s" % ", ".join(tables))
    zmq_sub(bind, tables)
    mysql_pub(master_dsn, blocking=blocking)
예제 #4
0
def main(master_dsn, redis_dsn, tables, namespace=None, blocking=False):
    setup_logger()

    logger = logging.getLogger(__name__)

    # currently only supports mysql master
    assert master_dsn and master_dsn.startswith("mysql")
    assert redis_dsn and redis_dsn.startswith("redis")

    logger.info("event sourcing tables: %s" % ", ".join(tables))
    es_sub(redis_dsn, tables, namespace)
    mysql_pub(master_dsn, blocking=blocking)
예제 #5
0
파일: mzmq.py 프로젝트: amumu/meepo
def main(bind, master_dsn, tables, blocking=False):
    setup_logger("INFO")

    logger = logging.getLogger(__name__)

    # currently only supports mysql master
    assert master_dsn and master_dsn.startswith("mysql")
    assert bind.startswith("ipc") or bind.startswith("tcp")

    logger.info("event sourcing tables: %s" % ", ".join(tables))
    zmq_sub(bind, tables)
    mysql_pub(master_dsn, blocking=blocking)
예제 #6
0
def main(master_dsn, redis_dsn, tables, namespace=None, blocking=False):
    setup_logger()

    logger = logging.getLogger(__name__)

    # currently only supports mysql master
    assert master_dsn and master_dsn.startswith("mysql")
    assert redis_dsn and redis_dsn.startswith("redis")

    logger.info("event sourcing tables: %s" % ", ".join(tables))
    es_sub(redis_dsn, tables, namespace)
    mysql_pub(master_dsn, blocking=blocking)
예제 #7
0
파일: mzdevice.py 프로젝트: amumu/meepo
def main(frontend_bind, backend_bind):
    setup_logger("INFO")

    logger = logging.getLogger(__name__)

    assert frontend_bind and backend_bind

    try:
        ctx = zmq.Context()
        frontend = ctx.socket(zmq.SUB)
        frontend.bind(frontend_bind)
        frontend.setsockopt(zmq.SUBSCRIBE, b"")

        backend = ctx.socket(zmq.PUB)
        backend.bind(backend_bind)

        zmq.device(zmq.FORWARDER, frontend, backend)

    except Exception as e:
        logger.exception(e)

    finally:
        frontend.close()
        backend.close()
예제 #8
0
def main(frontend_bind, backend_bind):
    setup_logger("INFO")

    logger = logging.getLogger(__name__)

    assert frontend_bind and backend_bind

    try:
        ctx = zmq.Context()
        frontend = ctx.socket(zmq.SUB)
        frontend.bind(frontend_bind)
        frontend.setsockopt(zmq.SUBSCRIBE, b"")

        backend = ctx.socket(zmq.PUB)
        backend.bind(backend_bind)

        zmq.device(zmq.FORWARDER, frontend, backend)

    except Exception as e:
        logger.exception(e)

    finally:
        frontend.close()
        backend.close()
예제 #9
0
파일: mysql_demo.py 프로젝트: amumu/meepo
# -*- coding: utf-8 -*-

"""
meepo_examples.tutorial.mysql
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

A demo script on how to use meepo with mysql row-based binlog.
"""

import logging

import click
import pymysql

from meepo.logutils import setup_logger
setup_logger()
logger = logging.getLogger("meepo_examples.tutorial.mysql")

from meepo._compat import urlparse


def db_prepare(dsn):
    parsed = urlparse(dsn)
    db_settings = {
        "host": parsed.hostname,
        "port": parsed.port or 3306,
        "user": parsed.username,
        "passwd": parsed.password
    }
    conn = pymysql.connect(**db_settings)
예제 #10
0
# -*- coding: utf-8 -*-
"""
meepo_examples.tutorial.sqlalchemy
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

A demo script on how to use meepo with sqlalchemy.
"""

import logging

import sqlalchemy as sa
from sqlalchemy.orm import sessionmaker, scoped_session
from sqlalchemy.ext.declarative import declarative_base

from meepo.logutils import setup_logger
setup_logger()
logger = logging.getLogger("meepo_examples.tutorial.sqlalchemy")

Base = declarative_base()


class Test(Base):
    __tablename__ = "test"

    id = sa.Column(sa.Integer, primary_key=True)
    data = sa.Column(sa.String)


def session_prepare(dsn):
    engine = sa.create_engine(dsn)
    session = scoped_session(sessionmaker(bind=engine))