Drain a fixed backlog of arrivals against a bounded depth and turn the remaining depth into a drain, steady, or throttle remediation action.

Async Queue Remediation Report

async_queue.lua
local arrivals = 
local depth = 4
local drained = arrivals
if drained > depth then
  drained = depth
end
local remaining = depth - drained

local action = "steady"
if drained <= 1 then
  action = "drain"
elseif remaining == 0 then
  action = "throttle"
end

print("arrivals=" .. arrivals .. " drained=" .. drained .. " remaining=" .. remaining .. " " .. action)
local arrivals = 
local depth = 4
local drained = arrivals
if drained > depth then
  drained = depth
end
local remaining = depth - drained

local action = "steady"
if drained <= 1 then
  action = "drain"
elseif remaining == 0 then
  action = "throttle"
end

print("arrivals=" .. arrivals .. " drained=" .. drained .. " remaining=" .. remaining .. " " .. action)
local arrivals = 
local depth = 4
local drained = arrivals
if drained > depth then
  drained = depth
end
local remaining = depth - drained

local action = "steady"
if drained <= 1 then
  action = "drain"
elseif remaining == 0 then
  action = "throttle"
end

print("arrivals=" .. arrivals .. " drained=" .. drained .. " remaining=" .. remaining .. " " .. action)
backlog depth The backlog depth and arrivals are scalars, so the remaining capacity that drives the remediation action stays deterministic without draining a live queue.