add websocket health information

This commit is contained in:
chris meyers
2020-02-05 09:03:04 -05:00
committed by Ryan Petrello
parent ea29f4b91f
commit 403e9bbfb5
3 changed files with 235 additions and 33 deletions

View File

@@ -122,6 +122,29 @@ class BroadcastConsumer(AsyncJsonWebsocketConsumer):
await self.send(event['text'])
class HealthConsumer(AsyncJsonWebsocketConsumer):
async def connect(self):
try:
WebsocketSecretAuthHelper.is_authorized(self.scope)
except Exception:
await self.close()
return
# TODO: log ip of connected client
logger.info("Client connected to health endpoint")
await self.accept()
async def disconnect(self, code):
# TODO: log ip of disconnected client
logger.info("Client disconnected from health endpoint")
async def receive_json(self, content, **kwargs):
logger.debug(f"Got Health status {content}")
async def internal_message(self, event):
logger.info("Got internal message from health endpoint .. can this happen?")
class EventConsumer(AsyncJsonWebsocketConsumer):
async def connect(self):
user = self.scope['user']