tobogganSe connecter

packages

The Louise packages, each released on its own

Clone avec HTTPS, un jeton personnel en mot de passe, ou avec SSH, une clé ajoutée dans vos paramètres.

NomDernier commitDate
src/packages: resilience, throttle and secrets from the apps; fetch.request (ADR 0081)il y a 1 sem.
CHANGELOG.mdA repository of its own: README, CI, release checks, fixturesil y a 4 j
louise.tomlVersion every package 0.21.0, on louise 0.22.0il y a 4 j
README.mdpackages: resilience, throttle and secrets from the apps; fetch.request (ADR 0081)il y a 1 sem.
README.MD

resilience

What every service needs to stay up under load and failure, in pure Louise with log as its only dependency (ADR 0081). Promoted from the identical copies in starfleet, toki2 and the newsletter.

import resilience/gate
import resilience/rate_limit.{Admitted, Wait}
import resilience/retry

// At most 4 argon2 hashes at once: a burst of logins is refused (503)
// rather than piling up.
let hashing = gate.start 4
match gate.admitted hashing fn { argon2.hash password }
{ Ok(hash) -> ..., Error(gate.Full) -> ... }

// A token bucket per key, refilled continuously.
let limit = rate_limit.per_minute 10
let (limit, answer) = rate_limit.taken limit client now_ms
match answer { Admitted -> ..., Wait(seconds) -> ... }

// A start-up step that may fail for a while (the database coming up).
use pool <- retry.retried "database" [500, 1000, 2000, 4000] fn { connect () }
  • resilience/gate: at most limit jobs at once, in an actor; a job that finds every slot taken is refused (Full) at once. A slot frees itself after lifetime_ms (start_with; 30 s with start), even when its job's process died.
  • resilience/rate_limit: token buckets per key, a minute's worth at most; taken answers Admitted or Wait(seconds), wait_for how long a bucket's units take, cost a request's units.
  • resilience/retry: an action tried until it succeeds, waiting each of a list of delays between tries, each failure logged at warn; the last failure is returned.

Buckets shared by every instance, in PostgreSQL, are packages/throttle.