Skip to content

Should we track translators connected to a given django instance by name? #225

@samoehlert

Description

@samoehlert

Right now we just have a lot of assumptions of 1 translator to 1 django instance. with the heartbeat im trying to send for the health information we could add a hostname to the payload. and then we'd just have to alter the consumers to accept the hostname in the payfield and store that somewhere (redis?)

async def heartbeat(websocket, g):
    """Periodically send health status/route counts to Django."""
    logger.info("Heartbeat task started for %s", settings.translator_hostname)
    while True:
        try:
            v4_count = g.get_route_count(gobgp_pb2.Family.AFI_IP)
            v6_count = g.get_route_count(gobgp_pb2.Family.AFI_IP6)
            logger.info("Sending heartbeat: v4=%s, v6=%s", v4_count, v6_count)
            await websocket.send(
                json.dumps({
                    "type": "translator_heartbeat",
                    "message": {
                        "hostname": settings.translator_hostname,
                        "v4_count": v4_count,
                        "v6_count": v6_count,
                    },
                })
            )
        except Exception:
            logger.exception("Heartbeat failed")
        await asyncio.sleep(30)
async def receive_json(self, content):
    if content["type"] == "translator_check_resp":
        channel = content.pop("channel")
        content["type"] = "wui_check_resp"
        await self.channel_layer.send(channel, content)
    elif content["type"] == "translator_heartbeat":
        msg = content["message"]
        hostname = msg["hostname"]

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions