Design a parcel locker
medium 80 minModel a wall of doors where couriers leave parcels and customers collect them with a code.
Watch lesson4:48
Where it shows up
The same pattern appears across everyday software.
Redis: how keys expire
A key with a time to live is removed passively, when somebody asks for it and it is too late, and actively, by testing random keys in the background. Comparing at pick up and sweeping for lists is the same pair.
Amazon SQS: visibility timeout
A received message is hidden for a time, 30 seconds by default. It must be deleted, or it becomes visible again. A lease with a confirmed end, where software may take the thing back by itself.
HashiCorp Vault: leases
Each dynamic secret comes with a lease and a time to live. When it ends, Vault can revoke the secret, and the holder can no longer be sure that it works. It can be renewed, as a stay can be extended.
RFC 4226: throttling
The standard for counter-based one-time codes tells the checking server to limit attempts, because the codes are short. Our limit at the keypad is that rule.
NIST SP 800-63B
The US guideline for digital authentication accepts a secret sent over another channel only once, and only for a short time (10 minutes there). A door code lives longer, so it needs more digits and a limit.
Python: secrets
The documentation says to use `secrets` and not the default generator of `random` for anything that protects something. `randbelow` and `compare_digest` on this page come from it.
Kubernetes: controllers
A controller watches the actual state and moves it towards the wanted one, over and over. The documentation uses a thermostat as its picture. Comparing doors with states each minute is a control loop.
SQLite: atomic commit
Its documentation explains how a transaction stays whole when the power fails in the middle of a write. This is why the journal of a wall can be one small file.