Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

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

ColumnContent
ownerThe 16 bytes of the tenant or the user
placeJSON of the application’s own type, at most 4 KiB
statecreating, active, moving or removing
generation1, and one more with each move
createdTime

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

StateA requestNext
creating503 not_ready, Retry-Afteractive, when the application’s work says that the data is there
activeThe place and its generationmoving, removing
moving503 moving, Retry-Afteractive with the new place and the next generation, or the old place
removing404 not_foundGone, 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.