Metadata-Version: 2.0
Name: miPubSub
Version: 0.1.dev1
Summary: Publish/Subscribe pattern build with RabbitMQ and Protocol Buffers
Home-page: https://github.com/azylinski/miPubSub
Author: https://twitter.com/ArturZylinski
Author-email: UNKNOWN
License: UNKNOWN
Description-Content-Type: UNKNOWN
Keywords: publish-subscribe rabbitmq protobuf docker async
Platform: UNKNOWN
Classifier: Development Status :: 1 - Planning
Classifier: Intended Audience :: Developers
Classifier: Topic :: Software Development :: Build Tools
Classifier: License :: OSI Approved :: MIT License
Classifier: Natural Language :: English
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: Implementation :: PyPy
Classifier: Topic :: Communications
Classifier: Topic :: Internet
Classifier: Topic :: Software Development :: Libraries
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: System :: Networking
Classifier: Topic :: System :: Software Distribution
Classifier: Topic :: Utilities
Requires-Dist: pika (>=0.11.2)
Requires-Dist: protobuf (>=3.5.1)

WIP: miPubSub
=============

Publish/Subscribe pattern build with RabbitMQ and Protocol Buffers.

Installation
------------

To install miPubSub, use `pipenv <http://pipenv.org/>`_ (or pip):

.. code-block:: bash

    $ pipenv install -e git@github.com:azylinski/miPubSub.git@master#egg=miPubSub


Run RabbitMQ
------------

In order to use miPubSub, you need to have access to RabbitMQ server.
To setup locally with `docker <https://docs.docker.com/engine/installation/>`_:

.. code-block:: bash

    docker run -d \
      --name demo-rabbit \
      -p 5672:5672 \
      -p 15672:15672 \
      rabbitmq:3.6.15-management-alpine


Define events structure
-----------------------

.. code-block::

    # schemas/events/user.proto

    syntax = "proto3";

    package events;


    message User {
      string name = 1;
      string email = 2;
    }


.. code-block:: bash

    # compile proto files
    protoc -I=schemas/events/ --python_out=proto/ schemas/events/*.proto


Example
-------

.. code-block:: python

    # producer.py

    from miPubSub import PubSub
    from proto.user_pb2 import User


    ps = PubSub('user_management')

    u = User(name='Adam West', email='adam.west@mail.com')

    ps.publish('signup_completed', u)


.. code-block:: python

    # consumer.py

    from miPubSub import PubSub
    from proto.user_pb2 import User


    ps = PubSub('mailer')

    @ps.listen('signup_completed', User)
    def on_signup_completed(user):
        # Send welcome email to: user.email
        pass

    ps.run()


How it works
------------

TBD

More details on rabbitmq pub/sub: https://www.rabbitmq.com/tutorials/tutorial-three-python.html


Authors
-------

- `@ArturZylinski <https://twitter.com/ArturZylinski>`_


License
-------

This project is licensed under the MIT License - see the `LICENSE <LICENSE>`_ file for details


