🔍 Overview
The MirrorRule model defines a one-to-one relationship between a main link and its mirror (backup) link, supporting failover logic and switching via the Voluum tracking system.
📑 Fields
| Field | Type | Description |
|---|---|---|
main_link | Foreign Key Link | The main link in the pair. |
mirror_link | Foreign Key Link | The backup (mirror) link. |
created_at | datetime | Timestamp when the rule was created. |
updated_at | datetime | Timestamp when the rule was last updated. |
switched | bool | Indicates whether the mirror link has replaced the main one. |
switched_at | datetime | Time of the last successful switch. |
owner | Foreign Key User Model | User who owns the rule and its links. |
🧩 Methods
switch(action_by="system")
Attempts to switch traffic from the main_link to the mirror_link by updating the Voluum tracking system.
Behavior
- Prevents duplicate switching.
- Updates the Voluum tracking system with the new (backup) link.
- Sends Telegram notifications:
- On success: Switching Link Successful message.
- On Voluum failure: Switching Link Failed (Voluum error) message.
- If no further backups: Switching Link Failed (no backups links) message.
- Marks the mirror link as
ACTIVEand updatesswitchedfield toTrue. - Marks failed mirrors as
IGNORED.