Simplify callback protocol for register_json_consumer().

The register_json_consumer() function now expects its callback
function to accept a single argument, which is the payload, as
none of the callbacks cared about channel, method, and properties.

This change breaks down as follows:

    * A couple test stubs and subclasses were simplified.
    * All the consume() and consume_wrapper() functions in
      queue_processors.py were simplified.
    * Two callbacks via runtornado.py were simplified.  One
      of the callbacks was socket.respond_send_message, which
      had an additional caller, i.e. not register_json_consumer()
      calling back to it, and the caller was simplified not
      to pass None for the three removed arguments.

(imported from commit 792316e20be619458dd5036745233f37e6ffcf43)
This commit is contained in:
Steve Howell
2013-10-30 17:03:50 -04:00
parent f1e90086f5
commit 70c1c31b3a
5 changed files with 17 additions and 19 deletions

View File

@@ -110,7 +110,7 @@ class SimpleQueueClient(object):
def register_json_consumer(self, queue_name, callback):
def wrapped_callback(ch, method, properties, body):
return callback(ch, method, properties, ujson.loads(body))
return callback(ujson.loads(body))
return self.register_consumer(queue_name, wrapped_callback)
def drain_queue(self, queue_name, json=False):