The Priority Queue decides which command goes next for each device. It is a per-device ordered queue that lets a high-priority command — say an emergency shutdown — overtake a backlog of routine configuration pushes.
Why per-device
A device processes one command at a time and may be offline for long stretches. Ordering per device keeps a slow or absent device from blocking delivery to the rest of the fleet.
Each device has its own queue implemented as a Redis sorted set, scored by
(priority, enqueue_time):
Lower priority numbers are delivered first (0 = most urgent, 9 = routine), so critical commands always jump the line.