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:
parent
c4c1429989
commit
62beb24d62
13
awx/main/consumers.py
Normal file
13
awx/main/consumers.py
Normal 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
6
awx/main/routing.py
Normal 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_]+)/$'),
|
||||
]
|
Loading…
Reference in New Issue
Block a user