README.rst
1=========
2pika-pool
3=========
4
5.. image:: https://travis-ci.org/bninja/pika-pool.png
6 :target: https://travis-ci.org/bninja/pika-pool
7
8.. image:: https://coveralls.io/repos/bninja/pika-pool/badge.png?branch=master
9 :target: https://coveralls.io/r/bninja/pika-pool?branch=master
10
11Pika connection pooling inspired by:
12
13- `flask-pika <https://github.com/WeatherDecisionTechnologies/flask-pika>`_
14- `sqlalchemy.pool.Pool <http://docs.sqlalchemy.org/en/latest/core/pooling.html#sqlalchemy.pool.Pool>`_
15
16Typically you'll go with local `shovels <https://www.rabbitmq.com/shovel.html>`_, `krazee-eyez kombu <http://bit.ly/1txcnnO>`_, etc. but this works too.
17
18usage
19-----
20
21Get it:
22
23.. code:: bash
24
25 pip install pika-pool
26
27and use it:
28
29.. code:: python
30
31 import json
32
33 import pika
34 import pika_pool
35
36 params = pika.URLParameters(
37 'amqp://guest:guest@localhost:5672/?'
38 'socket_timeout=10&'
39 'connection_attempts=2'
40 )
41
42 pool = pika_pool.QueuedPool(
43 create=lambda: pika.BlockingConnection(parameters=params),
44 max_size=10,
45 max_overflow=10,
46 timeout=10,
47 recycle=3600,
48 stale=45,
49 )
50
51 with pool.acquire() as cxn:
52 cxn.channel.basic_publish(
53 body=json.dumps({
54 'type': 'banana',
55 'description': 'they are yellow'
56 }),
57 exchange='',
58 routing_key='fruits',
59 properties=pika.BasicProperties(
60 content_type='application/json',
61 content_encoding='utf-8',
62 delivery_mode=2,
63 )
64 )
65
66release
67-------
68
69Tests pass:
70
71.. code:: bash
72
73 py.test test.py --cov=pika_pool --cov-report term-missing
74
75so update ``__version__`` in:
76
77- ``__init__.py``
78
79then commit and tag it:
80
81.. code:: bash
82
83 git commit -am "release v{version}"
84 git tag -a v{version} -m "release v{version}"
85 git push --tags
86
87and `travis <https://travis-ci.org/bninja/pika-pool>`_ will publish it to `pypi <https://pypi.python.org/pypi/pika-pool/>`_.
88