Skip to content

Commit

Permalink
Add echo channel and fix __str__ on redis backend
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewgodwin committed Nov 6, 2015
1 parent a41516f commit f3c3a23
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion channels/backends/redis_py.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,4 +183,4 @@ def unlock_channel(self, channel):
self.connection(self.consistent_hash(channel)).delete(key)

def __str__(self):
return "%s(host=%s, port=%s)" % (self.__class__.__name__, self.host, self.port)
return "%s(hosts=%s)" % (self.__class__.__name__, self.hosts)
10 changes: 10 additions & 0 deletions channels/consumer_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ class ConsumerRegistry(object):

def __init__(self, routing=None):
self.consumers = {}
# Add basic internal consumers
self.add_consumer(self.echo_consumer, ["__channels__.echo"])
# Initialise with any routing that was passed in
if routing:
# If the routing was a string, import it
Expand Down Expand Up @@ -56,3 +58,11 @@ def consumer_for_channel(self, channel):
return self.consumers[channel]
except KeyError:
return None

def echo_consumer(self, message):
"""
Implements the echo message standard.
"""
message.reply_channel.send({
"content": message.content.get("content", None),
})

0 comments on commit f3c3a23

Please sign in to comment.