summaryrefslogtreecommitdiff
path: root/docs/userguide
diff options
context:
space:
mode:
authorAsk Solem <ask@celeryproject.org>2016-04-07 15:59:26 -0700
committerAsk Solem <ask@celeryproject.org>2016-04-07 17:29:30 -0700
commit719ce2ef78d14ddfdb1f0cab52dbc771274450a1 (patch)
tree3e8dbcce266e754cbd61b6f3aee8bbd9970f4db2 /docs/userguide
parentd7316fea10e6eba053886a683b0a26076338be63 (diff)
downloadkombu-719ce2ef78d14ddfdb1f0cab52dbc771274450a1.tar.gz
Use celery_sphinx to manage docs
Diffstat (limited to 'docs/userguide')
-rw-r--r--docs/userguide/connections.rst40
-rw-r--r--docs/userguide/consumers.rst4
-rw-r--r--docs/userguide/pools.rst8
-rw-r--r--docs/userguide/serialization.rst12
-rw-r--r--docs/userguide/simple.rst4
5 files changed, 50 insertions, 18 deletions
diff --git a/docs/userguide/connections.rst b/docs/userguide/connections.rst
index daec191b..0e174e81 100644
--- a/docs/userguide/connections.rst
+++ b/docs/userguide/connections.rst
@@ -13,7 +13,9 @@ To send and receive messages you need a transport and a connection.
There are several transports to choose from (amqp, librabbitmq, redis, qpid, in-memory, etc.),
and you can even create your own. The default transport is amqp.
-Create a connection using the default transport::
+Create a connection using the default transport:
+
+.. code-block:: pycon
>>> from kombu import Connection
>>> connection = Connection('amqp://guest:guest@localhost:5672//')
@@ -21,23 +23,31 @@ Create a connection using the default transport::
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.connect`
-method::
+method:
+
+.. code-block:: pycon
>>> connection.connect()
-You can also check whether the connection is connected::
+You can also check whether the connection is connected:
+
+.. code-block:: pycon
>>> connection.connected
True
-Connections must always be closed after use::
+Connections must always be closed after use:
+
+.. code-block:: pycon
>>> connection.close()
But best practice is to release the connection instead,
this will release the resource if the connection is associated
with a connection pool, or close the connection if not,
-and makes it easier to do the transition to connection pools later::
+and makes it easier to do the transition to connection pools later:
+
+.. code-block:: pycon
>>> connection.release()
@@ -47,7 +57,9 @@ and makes it easier to do the transition to connection pools later::
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::
+resources:
+
+.. code-block:: python
with Connection() as connection:
# work with connection
@@ -57,11 +69,15 @@ resources::
URLs
====
-Connection parameters can be provided as an URL in the format::
+Connection parameters can be provided as an URL in the format:
+
+.. code-block:: text
transport://userid:password@hostname:port/virtual_host
-All of these are valid URLs::
+All of these are valid URLs:
+
+.. code-block:: text
# Specifies using the amqp transport only, default values
# are taken from the keyword arguments.
@@ -82,7 +98,9 @@ All of these are valid URLs::
# Using virtual host 'foo'
amqp://localhost/foo
-The query part of the URL can also be used to set options, e.g.::
+The query part of the URL can also be used to set options, e.g.:
+
+.. code-block:: text
amqp://localhost/myvhost?ssl=1
@@ -91,7 +109,9 @@ See :ref:`connection-options` for a list of supported options.
A connection without options will use the default connection settings,
which is using the localhost host, default port, user name `guest`,
password `guest` and virtual host "/". A connection without arguments
-is the same as::
+is the same as:
+
+.. code-block:: pycon
>>> Connection('amqp://guest:guest@localhost:5672//')
diff --git a/docs/userguide/consumers.rst b/docs/userguide/consumers.rst
index 7a513f5a..e76a88b6 100644
--- a/docs/userguide/consumers.rst
+++ b/docs/userguide/consumers.rst
@@ -18,7 +18,9 @@ drain events from all channels on that connection.
Kombu since 3.0 will only accept json/binary or text messages by default,
to allow deserialization of other formats you have to specify them
- in the ``accept`` argument::
+ in the ``accept`` argument:
+
+ .. code-block:: python
Consumer(conn, accept=['json', 'pickle', 'msgpack', 'yaml'])
diff --git a/docs/userguide/pools.rst b/docs/userguide/pools.rst
index 69d3acba..3c4b9d81 100644
--- a/docs/userguide/pools.rst
+++ b/docs/userguide/pools.rst
@@ -29,7 +29,9 @@ This is a pool group, which means you give it a connection instance,
and you get a pool instance back. We have one pool per connection
instance to support multiple connections in the same app.
All connection instances with the same connection parameters will
-get the same pool::
+get the same pool:
+
+.. code-block:: pycon
>>> from kombu import Connection
>>> from kombu.pools import connections
@@ -124,7 +126,9 @@ By default every connection instance has a limit of 200 connections.
You can change this limit using :func:`kombu.pools.set_limit`.
You are able to grow the pool at runtime, but you can't shrink it,
so it is best to set the limit as early as possible after your application
-starts::
+starts:
+
+.. code-block:: pycon
>>> from kombu import pools
>>> pools.set_limit()
diff --git a/docs/userguide/serialization.rst b/docs/userguide/serialization.rst
index 5ef3738e..799c565c 100644
--- a/docs/userguide/serialization.rst
+++ b/docs/userguide/serialization.rst
@@ -85,13 +85,17 @@ Each option has its advantages and disadvantages.
To instruct `Kombu` to use an alternate serialization method,
use one of the following options.
- 1. Set the serialization option on a per-producer basis::
+ 1. Set the serialization option on a per-producer basis:
+
+ .. code-block:: pycon
>>> producer = Producer(channel,
... exchange=exchange,
... serializer='yaml')
- 2. Set the serialization option per message::
+ 2. Set the serialization option per message:
+
+ .. code-block:: pycon
>>> producer.publish(message, routing_key=rkey,
... serializer='pickle')
@@ -110,7 +114,9 @@ pass in a plain string or Unicode object as your message and a custom `content_t
not waste cycles serializing/deserializing the data.
You can optionally specify a `content_encoding`
-for the raw data::
+for the raw data:
+
+.. code-block:: pycon
>>> with open('~/my_picture.jpg', 'rb') as fh:
... producer.publish(fh.read(),
diff --git a/docs/userguide/simple.rst b/docs/userguide/simple.rst
index 4cf98ec6..c65d72c8 100644
--- a/docs/userguide/simple.rst
+++ b/docs/userguide/simple.rst
@@ -21,7 +21,7 @@ a :class:`~kombu.Queue` as the name argument instead.
In addition, the :class:`~kombu.Connection` comes with
shortcuts to create simple queues using the current connection:
-.. code-block:: python
+.. code-block:: pycon
>>> queue = connection.SimpleQueue('myqueue')
>>> # ... do something with queue
@@ -30,7 +30,7 @@ shortcuts to create simple queues using the current connection:
This is equivalent to:
-.. code-block:: python
+.. code-block:: pycon
>>> from kombu import SimpleQueue, SimpleBuffer