🔍 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

FieldTypeDescription
main_linkForeign Key LinkThe main link in the pair.
mirror_linkForeign Key LinkThe backup (mirror) link.
created_atdatetimeTimestamp when the rule was created.
updated_atdatetimeTimestamp when the rule was last updated.
switchedboolIndicates whether the mirror link has replaced the main one.
switched_atdatetimeTime of the last successful switch.
ownerForeign Key User ModelUser 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 ACTIVE and updates switched field to True.
  • Marks failed mirrors as IGNORED.