15 Places
An application can keep its data apart from the auth tables: the auth database is then the directory database. It
has the users, the sessions, the tenants, the memberships, and for each tenant or user its place. The data is in
one or many other databases. The table is the feature places (10).
Choice
An application places by tenant or by user. It chooses one when it is set up, and never has both. By tenant, a request outside a tenant has no place.
Place
| Column | Content |
|---|---|
owner | The 16 bytes of the tenant or the user |
place | JSON of the application’s own type, at most 4 KiB |
state | creating, active, moving or removing |
generation | 1, and one more with each move |
created | Time |
The library does not read the content. It MUST NOT hold credentials: a password belongs to the configuration of the server that opens the database.
States
| State | A request | Next |
|---|---|---|
creating | 503 not_ready, Retry-After | active, when the application’s work says that the data is there |
active | The place and its generation | moving, removing |
moving | 503 moving, Retry-After | active with the new place and the next generation, or the old place |
removing | 404 not_found | Gone, when the application’s work says that the data is gone |
Work
A new place and its work are in the commit that creates the tenant or the user. A removal and its work are in one commit too. The work is in the outbox (02) and runs at least once after the commit.
- Each call has an ID. A call can come again with the same ID, so the application’s work MUST be safe to repeat.
- Each piece of work has a lease of 300 seconds†. Any number of runners can run at once, and one piece runs in one place at a time. Work that takes longer than its lease can run twice. Work that fails stays, and runs again when its lease ends.
- Work to provision a place that no longer waits for it, for example after a removal, is dropped.
- After a move, the data at the old place is the application’s to delete.
- The application lists places that wait too long by their state.
Costs
A separate directory has no transaction across users and data, no foreign keys to users, and no consistent backup of both. The application keeps names that it shows in its own data. A restored directory has sessions that ended since the copy: after a restore, end all sessions, tokens and API keys.