Package couchdbkit :: Package consumer :: Class Consumer
[hide private]
[frames] | no frames]

Class Consumer

source code

object --+
         |
        Consumer

Database change consumer

Example Usage:

>>> from couchdbkit import Server, Consumer
>>> s = Server()
>>> db = s['testdb']
>>> c = Consumer(db)
>>> def print_line(line):
...     print "got %s" % line
... 
>>> c.wait(print_line,since=0) # Go into receive loop
Instance Methods [hide private]
 
__init__(self, db, backend='couchdbkit.consumer.sync.SyncConsumer', **kwargs)
Constructor for the consumer
source code
 
fetch(self, cb=None, **params)
Fetch all changes and return.
source code
 
wait_once(self, cb=None, **params)
Wait for one change and return (longpoll feed)
source code
 
wait(self, cb, **params)
Wait for changes until the connection close (continuous feed)
source code
 
wait_once_async(self, cb, **params)
like wait_once but doesn't return anything.
source code
 
wait_async(self, cb, **params)
like wait but doesn't return anything.
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, db, backend='couchdbkit.consumer.sync.SyncConsumer', **kwargs)
(Constructor)

source code 
Constructor for the consumer

Args:
@param db: Database instance
@param backend: backend entry point uri
The default class (sync) erialize each call to registered
callbacks. Line processing should be fast in this case to not
wait on socket read.

 A string referring to one of the following bundled classes:

* ``sync``
* ``eventlet`` - Requires eventlet >= 0.9.7
* ``gevent``   - Requires gevent >= 0.12.2 (?)

You can optionnaly register in ``couchdbkit.consumers``entry point 
your own worker.

Overrides: object.__init__

fetch(self, cb=None, **params)

source code 

Fetch all changes and return. If since is specified, fetch all changes since this doc sequence

Args:

Parameters:
  • params - kwargs See Changes API (http://wiki.apache.org/couchdb/HTTP_database_API#Changes)
Returns:
dict, change result

wait_once(self, cb=None, **params)

source code 

Wait for one change and return (longpoll feed)

Args:

Parameters:
  • params - kwargs See Changes API (http://wiki.apache.org/couchdb/HTTP_database_API#Changes)
Returns:
dict, change result

wait(self, cb, **params)

source code 

Wait for changes until the connection close (continuous feed)

Args:

Parameters:
  • params - kwargs See Changes API (http://wiki.apache.org/couchdb/HTTP_database_API#Changes)
Returns:
dict, line of change