Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New API #29

Open
ask opened this issue May 30, 2010 · 0 comments
Open

New API #29

ask opened this issue May 30, 2010 · 0 comments

Comments

@ask
Copy link
Owner

ask commented May 30, 2010

The current Consumer/Publisher classes hides the channels, I think we should rethink the API altogether.

Braindump:

from carrot import Connection, Consumer, Producer

connection = Connection(host="localhost", user="guest", "password="guest", vhost="/")

channel = connection.Channel()
consumer = Consumer(channel, queue="celery", exchange="celery", routing_key="celery")
consumer.register_callback(process_task)

while True:
    connection.drain_events()
    # or channel.drain_events() will only receive events on that channel.

producer = Producer(channel, exchange="celery")
producer.publish({"task": "celery.ping", args=[], kwargs={}}, serializer="pickle")

A ConsumerSet is now simply using the same channel with more than one consumer:

channel = connection.Channel()
c1 = Consumer(channel, queue="foo")
c2 = Consumer(channel, queue="bar")
c3 = Consumer(channel, queue="baz")

while True:
    connection.drain_events()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant