1
0
mirror of https://github.com/ansible/awx.git synced 2024-11-02 09:51:09 +03:00

adding initial testing consumers/routes for channels

This commit is contained in:
Wayne Witzel III 2016-08-08 12:53:04 -04:00
parent c4c1429989
commit 62beb24d62
2 changed files with 19 additions and 0 deletions

13
awx/main/consumers.py Normal file
View File

@ -0,0 +1,13 @@
from channels import Group
from channels.sessions import channel_session
@channel_session
def job_event_connect(message):
job_id = message.content['path'].strip('/')
message.channel_session['job_id'] = job_id
Group("job_events-%s" % job_id).add(message.reply_channel)
def emit_channel_notification(event, payload):
Group(event).send(payload)

6
awx/main/routing.py Normal file
View File

@ -0,0 +1,6 @@
from channels.routing import route
channel_routing = [
route("websocket.connect", "awx.main.consumers.job_event_connect", path=r'^/job_event/(?P<id>[a-zA-Z0-9_]+)/$'),
]