mirror of https://github.com/celery/kombu.git
Added API to readme
This commit is contained in:
parent
da3e754594
commit
fe5074208d
33
README.rst
33
README.rst
|
@ -6,6 +6,39 @@
|
|||
|
||||
**THIS IS A REWRITE OF CARROT**
|
||||
|
||||
Proposed API::
|
||||
|
||||
from kombu.connection Connection
|
||||
from kombu.messaging import Exchange, Binding, Consumer, Producer
|
||||
|
||||
media_exchange = Exchange("media", "direct", durable=True)
|
||||
video_binding = Binding("video", exchange=media_exchange, key="video")
|
||||
|
||||
# connections/channels
|
||||
connection = Connection("localhost", "guest", "guest", "/")
|
||||
channel = connection.channel()
|
||||
|
||||
# produce
|
||||
producer = Producer(channel, exchange=media_exchange, serializer="json")
|
||||
producer.publish({"name": "/tmp/lolcat1.avi", "size": 1301013})
|
||||
|
||||
# consume
|
||||
consumer = Consumer(channel, video_binding)
|
||||
consumer.register_callback(process_media)
|
||||
consumer.consume()
|
||||
|
||||
while True:
|
||||
connection.drain_events()
|
||||
|
||||
|
||||
# consumerset:
|
||||
video_binding = Binding("video", exchange=media_exchange, key="video")
|
||||
image_binding = Binding("image", exchange=media_exchange, key="image")
|
||||
|
||||
consumer = Consumer(channel, [video_binding, image_binding])
|
||||
|
||||
|
||||
**ORIGINAL CARROT README BELOW**
|
||||
|
||||
Introduction
|
||||
------------
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
.. code-block:: python
|
||||
|
||||
from carrot import Connection, Exchange, Binding
|
||||
from carrot import Consumer, Producer
|
||||
from kombu.connection Connection
|
||||
from kombu.messaging import Exchange, Binding, Consumer, Producer
|
||||
|
||||
media_exchange = Exchange("media", "direct", durable=True)
|
||||
video_binding = Binding("video", exchange=media_exchange, key="video")
|
||||
|
@ -30,12 +30,3 @@
|
|||
image_binding = Binding("image", exchange=media_exchange, key="image")
|
||||
|
||||
consumer = Consumer(channel, [video_binding, image_binding])
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue