Rate Limit Safety/Durability Levels

RateLim.it limiters currently come in two levels.

Each limit definition that you create can be created at any durability level.

L4_BEST_EFFORT [Default]

L5_BOMBPROOF

@limiter = RateLimit::Limiter.new(apikey: "ACCT_ID|APIKEY")

def basic

  # 60/minute, non-returnable, burst size of 10
  ld = RateLimit::LimitDefinition.new("grp", 60, RateLimit::MINUTELY, false, 10)

  #ld.safety_level = RateLimit::L4_BEST_EFFORT
  #override default safety_level to bombproof
  ld.safety_level = RateLimit::L5_BOMBPROOF

  @limiter.upsert(ld, :put)

  (0..1000).each do ||
    if @limiter.pass?("grp:4")
      puts "do it!"
    else
      puts "dont"
    end
    sleep(0.1)
  end
end