Skip to main content

Module machine_id

Module machine_id 

Source
Expand description

The machine id file: where the daemon’s MachineId lives on disk, how the daemon mints it once, and how an operator replaces it.

The file is <data home>/cortexkit/machine-id, one line of 32 lowercase hex characters. The daemon reads it at startup, before it accepts a connection, and mints it only when it is absent. It never rewrites a present file: a file that does not parse stops the daemon with MachineIdFileError::Corrupt, because silently replacing a corrupt identity would hand every module a new name for the same machine. Only ck machine adopt replaces the value, and it takes effect at the next daemon start.

See MachineId for the rule every holder of the value must follow: it is a name, never an authority.

Structs§

MachineId
This machine’s name, minted once by the daemon and served to every module that registers with it (on HELLO_ACK and server.describe).

Enums§

MachineIdError
Why a string is not a machine id.
MachineIdFileError
Why the daemon could not establish its machine id.

Constants§

MACHINE_ID_FILE_NAME
File name of the machine id under <data home>/cortexkit/.

Functions§

default_machine_id_path
Resolve <data home>/cortexkit/machine-id from the same data home the daemon uses for storage.
load_or_mint
Read the machine id at path, minting and writing a fresh one when the file is absent. A present file is only ever read, never rewritten.
read
Read and validate the machine id at path. Ok(None) means the file does not exist; any other read failure, or content that is not exactly 32 lowercase hex characters (one trailing newline allowed), is an error.
write
Write id to path through a temporary file in the same directory and a rename, so a reader sees either the old file or the complete new one.