summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorAsk Solem <ask@celeryproject.org>2012-06-24 16:32:17 +0100
committerAsk Solem <ask@celeryproject.org>2012-06-24 16:32:17 +0100
commitfa816f6dc920aeb7b68b75f98fa1656da57d05c8 (patch)
treec2f2d076cc62ea62405fb6f267accab61d1f67c9 /docs
parent4922c4aaea77be7a32a7d904104b055159e0da3e (diff)
downloadkombu-fa816f6dc920aeb7b68b75f98fa1656da57d05c8.tar.gz
BrokerConnection is now Connection in docs
Diffstat (limited to 'docs')
-rw-r--r--docs/reference/kombu.connection.rst6
-rw-r--r--docs/reference/kombu.pidbox.rst2
-rw-r--r--docs/userguide/connections.rst12
-rw-r--r--docs/userguide/pools.rst38
-rw-r--r--docs/userguide/simple.rst44
5 files changed, 51 insertions, 51 deletions
diff --git a/docs/reference/kombu.connection.rst b/docs/reference/kombu.connection.rst
index 63c6b282..3b856bc5 100644
--- a/docs/reference/kombu.connection.rst
+++ b/docs/reference/kombu.connection.rst
@@ -10,7 +10,7 @@
Connection
----------
- .. autoclass:: BrokerConnection
+ .. autoclass:: Connection
.. admonition:: Attributes
@@ -44,8 +44,8 @@
.. seealso::
- The shortcut methods :meth:`BrokerConnection.Pool` and
- :meth:`BrokerConnection.ChannelPool` is the recommended way
+ The shortcut methods :meth:`Connection.Pool` and
+ :meth:`Connection.ChannelPool` is the recommended way
to instantiate these classes.
.. autoclass:: ConnectionPool
diff --git a/docs/reference/kombu.pidbox.rst b/docs/reference/kombu.pidbox.rst
index f47bfd4c..ebc72cd0 100644
--- a/docs/reference/kombu.pidbox.rst
+++ b/docs/reference/kombu.pidbox.rst
@@ -28,7 +28,7 @@
.. code-block:: python
- >>> connection = kombu.BrokerConnection()
+ >>> connection = kombu.Connection()
>>> state = {"beat": beat,
"connection": connection}
>>> consumer = mailbox(connection).Node(hostname).listen()
diff --git a/docs/userguide/connections.rst b/docs/userguide/connections.rst
index a1d7b176..14ff4aad 100644
--- a/docs/userguide/connections.rst
+++ b/docs/userguide/connections.rst
@@ -15,12 +15,12 @@ and you can even create your own. The default transport is amqplib.
Create a connection using the default transport::
- >>> from kombu import BrokerConnection
- >>> connection = BrokerConnection("amqp://guest:guest@localhost:5672//")
+ >>> from kombu import Connection
+ >>> connection = Connection('amqp://guest:guest@localhost:5672//')
The connection will not be established yet, as the connection is established
when needed. If you want to explicitly establish the connection
-you have to call the :meth:`~kombu.connection.BrokerConnection.connect`
+you have to call the :meth:`~kombu.connection.Connection.connect`
method::
>>> connection.connect()
@@ -49,7 +49,7 @@ Of course, the connection can be used as a context, and you are
encouraged to do so as it makes it harder to forget releasing open
resources::
- with BrokerConnection() as connection:
+ with Connection() as connection:
# work with connection
.. _connection-urls:
@@ -87,7 +87,7 @@ which is using the localhost host, default port, user name `guest`,
password `guest` and virtual host "/". A connection without arguments
is the same as::
- >>> BrokerConnection("amqp://guest:guest@localhost:5672//")
+ >>> Connection('amqp://guest:guest@localhost:5672//')
The default port is transport specific, for AMQP this is 5672.
@@ -100,7 +100,7 @@ the redis database number.
Keyword arguments
=================
-The :class:`BrokerConnection` class supports additional
+The :class:`~kombu.connection.Connection` class supports additional
keyword arguments, these are:
:hostname: Default host name if not provided in the URL.
diff --git a/docs/userguide/pools.rst b/docs/userguide/pools.rst
index 79c959ed..d921bc46 100644
--- a/docs/userguide/pools.rst
+++ b/docs/userguide/pools.rst
@@ -31,25 +31,25 @@ instance to support multiple connections in the same app.
All connection instances with the same connection parameters will
get the same pool::
- >>> from kombu import BrokerConnection
+ >>> from kombu import Connection
>>> from kombu.pools import connections
- >>> connections[BrokerConnection("redis://localhost:6379")]
+ >>> connections[Connection('redis://localhost:6379')]
<kombu.connection.ConnectionPool object at 0x101805650>
- >>> connections[BrokerConnection("redis://localhost:6379")]
+ >>> connections[Connection('redis://localhost:6379')]
<kombu.connection.ConnectionPool object at 0x101805650>
Let's acquire and release a connection:
.. code-block:: python
- from kombu import BrokerConnection
+ from kombu import Connection
from kombu.pools import connections
- connection = BrokerConnection("redis://localhost:6379")
+ connection = Connection('redis://localhost:6379')
with connections[connection].acquire(block=True) as conn:
- print("Got connection: %r" % (connection.as_uri(), ))
+ print('Got connection: %r' % (connection.as_uri(), ))
.. note::
@@ -69,11 +69,11 @@ at once you can do that too:
.. code-block:: python
- from kombu import BrokerConnection
+ from kombu import Connection
from kombu.pools import connections
- c1 = BrokerConnection("amqp://")
- c2 = BrokerConnection("redis://")
+ c1 = Connection('amqp://')
+ c2 = Connection('redis://')
with connections[c1].acquire(block=True) as conn1:
with connections[c2].acquire(block=True) as conn2:
@@ -93,27 +93,27 @@ to the ``news`` exchange:
.. code-block:: python
- from kombu import BrokerConnection, Exchange
+ from kombu import Connection, Exchange
from kombu.common import maybe_declare
from kombu.pools import producers
# The exchange we send our news articles to.
- news_exchange = Exchange("news")
+ news_exchange = Exchange('news')
# The article we want to send
- article = {"title": "No cellular coverage on the tube for 2012",
- "ingress": "yadda yadda yadda"}
+ article = {'title': 'No cellular coverage on the tube for 2012',
+ 'ingress': 'yadda yadda yadda'}
# The broker where our exchange is.
- connection = BrokerConnection("amqp://guest:guest@localhost:5672//")
+ connection = Connection('amqp://guest:guest@localhost:5672//')
with producers[connection].acquire(block=True) as producer:
# maybe_declare knows what entities have already been declared
# so we don't have to do so multiple times in the same process.
maybe_declare(news_exchange)
- producer.publish(article, routing_key="domestic",
- serializer="json",
- compression="zlib")
+ producer.publish(article, routing_key='domestic',
+ serializer='json',
+ compression='zlib')
.. _default-pool-limits:
@@ -153,12 +153,12 @@ instances:
.. code-block:: python
from kombu import pools
- from kombu import BrokerConnection
+ from kombu import Connection
connections = pools.Connection(limit=100)
producers = pools.Producers(limit=connections.limit)
- connection = BrokerConnection("amqp://guest:guest@localhost:5672//")
+ connection = Connection('amqp://guest:guest@localhost:5672//')
with connections[connection].acquire(block=True):
# ...
diff --git a/docs/userguide/simple.rst b/docs/userguide/simple.rst
index 650b8b28..81aeb641 100644
--- a/docs/userguide/simple.rst
+++ b/docs/userguide/simple.rst
@@ -18,10 +18,10 @@ two arguments, a connection channel and a name. The name is used as the
queue, exchange and routing key. If the need arises, you can specify
a :class:`~kombu.entity.Queue` as the name argument instead.
-In addition, the :class:`~kombu.connection.BrokerConnection` comes with
+In addition, the :class:`~kombu.connection.Connection` comes with
shortcuts to create simple queues using the current connection::
- >>> queue = connection.SimpleQueue("myqueue")
+ >>> queue = connection.SimpleQueue('myqueue')
>>> # ... do something with queue
>>> queue.close()
@@ -56,23 +56,23 @@ to produce and consume logging messages:
from socket import gethostname
from time import time
- from kombu import BrokerConnection
+ from kombu import Connection
class Logger(object):
- def __init__(self, connection, queue_name="log_queue",
- serializer="json", compression=None):
+ def __init__(self, connection, queue_name='log_queue',
+ serializer='json', compression=None):
self.queue = connection.SimpleQueue(self.queue_name)
self.serializer = serializer
self.compression = compression
- def log(self, message, level="INFO", context={}):
- self.queue.put({"message": message,
- "level": level,
- "context": context,
- "hostname": socket.gethostname(),
- "timestamp": time()},
+ def log(self, message, level='INFO', context={}):
+ self.queue.put({'message': message,
+ 'level': level,
+ 'context': context,
+ 'hostname': socket.gethostname(),
+ 'timestamp': time()},
serializer=self.serializer,
compression=self.compression)
@@ -87,28 +87,28 @@ to produce and consume logging messages:
self.queue.close()
- if __name__ == "__main__":
+ if __name__ == '__main__':
from contextlib import closing
- with BrokerConnection("amqp://guest:guest@localhost:5672//") as conn:
+ with Connection('amqp://guest:guest@localhost:5672//') as conn:
with closing(Logger(connection)) as logger:
# Send message
- logger.log("Error happened while encoding video",
- level="ERROR",
- context={"filename": "cutekitten.mpg"})
+ logger.log('Error happened while encoding video',
+ level='ERROR',
+ context={'filename': 'cutekitten.mpg'})
# Consume and process message
# This is the callback called when a log message is
# received.
def dump_entry(entry):
- date = datetime.fromtimestamp(entry["timestamp"])
- print("[%s %s %s] %s %r" % (date,
- entry["hostname"],
- entry["level"],
- entry["message"],
- entry["context"]))
+ date = datetime.fromtimestamp(entry['timestamp'])
+ print('[%s %s %s] %s %r' % (date,
+ entry['hostname'],
+ entry['level'],
+ entry['message'],
+ entry['context']))
# Process a single message using the callback above.
logger.process(dump_entry, n=1)