Skip to main content

Module commands

Module commands 

Source
Expand description

Command rows: written by the webserver, applied by the master, kept as the audit trail.

A command is decided once: pending becomes applied (with what it produced) or rejected (with a reason), and never changes again.

On Postgres a new command also sends a notification on COMMANDS_CHANNEL, so the master picks it up at once (Database::command_notifications); polling stays the fallback, and the only way on SQLite (see archive/PROJECT.md, Web UI and CLI).

Structs§

CommandNotifications
Notifications of new commands and posted named events (Postgres only): a dedicated connection listening on COMMANDS_CHANNEL and EVENTS_CHANNEL.
CommandRecord
A command row, as the CLI and the UI read it.
PendingCommand
A pending command, as the master reads it.

Enums§

Notified
What a notification announced.
Submitted
What Database::submit_command did.

Constants§

COMMANDS_CHANNEL
The Postgres notification channel a new command is announced on.
EVENTS_CHANNEL
The channel a named event posted through the API is announced on (decision 486): the master’s trigger loop looks at once. A lost one is found by the next tick’s probe (the post cleared its listeners’ stored time).

Functions§

listening_is_safe
Whether a LISTEN on connection y would stay on one Postgres server process, as directly or through a pooler in session mode; false behind a pooler in transaction mode (B16). Each round it reads y’s server process, opens a transaction on x (a pooler then usually lends x the server connection y just gave back), and reads y’s again while x holds it: x on y’s process (two clients on one server process: only a pooler does that) or y on another one is a pooler in transaction mode. Repeated, so a pooler that happens to lend other connections still shows.