Drain a fixed backlog at a selected rate and turn the remaining depth into a drain, steady, or throttle remediation action.

Queue Drain Remediation Report

queue_drain_remediation_report.rb
rate = 
depth = 4
drained = 0

rate.times do
  drained += 1 if drained < depth
end

remaining = depth - drained

action = if remaining >= 3
  "drain"
elsif remaining == 0
  "throttle"
else
  "steady"
end

puts "rate=#{rate}"
puts "drained=#{drained}"
puts "remaining=#{remaining}"
puts "action=#{action}"
rate = 
depth = 4
drained = 0

rate.times do
  drained += 1 if drained < depth
end

remaining = depth - drained

action = if remaining >= 3
  "drain"
elsif remaining == 0
  "throttle"
else
  "steady"
end

puts "rate=#{rate}"
puts "drained=#{drained}"
puts "remaining=#{remaining}"
puts "action=#{action}"
rate = 
depth = 4
drained = 0

rate.times do
  drained += 1 if drained < depth
end

remaining = depth - drained

action = if remaining >= 3
  "drain"
elsif remaining == 0
  "throttle"
else
  "steady"
end

puts "rate=#{rate}"
puts "drained=#{drained}"
puts "remaining=#{remaining}"
puts "action=#{action}"
backlog depth The backlog depth and the scalar drain rate together decide the remediation action, so the result is reproducible without any live queue object.