mirror of
https://github.com/django/daphne.git
synced 2025-04-21 17:22:03 +03:00
Add echo channel and fix __str__ on redis backend
This commit is contained in:
parent
a41516fa6b
commit
f3c3a239b9
|
@ -183,4 +183,4 @@ class RedisChannelBackend(BaseChannelBackend):
|
|||
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)
|
||||
|
|
|
@ -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
|
||||
|
@ -56,3 +58,11 @@ class ConsumerRegistry(object):
|
|||
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),
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue
Block a user