ilusm.dev

rate

rate limiting: token bucket, sliding window, leaky bucket.

Load with: use rate

Quick example

use rate

result = ratnw("value", 10)
prn(result)

Functions

Functions

ratnw(cap, per_ms)

Performs the operation. Takes cap, per_ms.

ratrf(r)

Performs the operation. Takes r.

ratal(r, n)

Performs the operation. Takes r, n.

ratwa(r, n)

Performs the operation. Takes r, n.

ratrm(r)

Removes an item. Takes r.

ratsw(mx, win_ms)

Performs the operation. Takes mx, win_ms.

ratsa(sw)

Performs the operation. Takes sw.

ratsc(sw)

Performs the operation. Takes sw.

ratlb(cap, drn_ms)

Performs the operation. Takes cap, drn_ms.

ratld(lb)

Performs the operation. Takes lb.

ratla(lb)

Performs the operation. Takes lb.

ratfx(mx, win_ms)

Performs the operation. Takes mx, win_ms.

ratfa(fx)

Performs the operation. Takes fx.

ratfr(fx)

Creates from another format. Takes fx.

Module aliases

These are the public-facing names you call with use rate:

  • rate.new(c, p)
  • rate.ok(r, n)
  • rate.wait(r, n)
  • rate.rem(r)
  • rate.sw(mx, w)
  • rate.swok(s)
  • rate.lb(c, d)
  • rate.lbok(l)
  • rate.fx(mx, w)
  • rate.fxok(f)

Notes

  • Rate limiting - token bucket, leaky bucket, sliding window.