Documentation
¶
Overview ¶
Package readiness publishes daemon startup records in owned private directories and reads them back for the process that launched the daemon.
Index ¶
Constants ¶
const MaxRecordSize = 4 << 10
MaxRecordSize bounds the bytes Read accepts from one readiness file.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Record ¶
type Record struct {
SchemaVersion int `json:"schema_version"`
PID int `json:"pid"`
HTTPAddr string `json:"http_addr,omitempty"`
GRPCAddr string `json:"grpc_addr,omitempty"`
ExecutorID string `json:"executor_id,omitempty"`
}
func Read ¶ added in v0.3.0
Read reads one published readiness record and checks it against the process that was supposed to publish it. The record is evidence that the daemon reached its own ready point: an existing process, or a service manager that merely created one, proves nothing on its own.
An empty executorID expects a dispatcher record: exactly schema_version, pid, http_addr and grpc_addr, with both addresses on 127.0.0.1 and a port from 1 to 65535. A nonempty executorID expects an executor record: exactly schema_version, pid and executor_id, carrying that identity. Any other or repeated field, a null value, trailing data, a schema version other than 1 or a PID other than pid refuses the record.
A missing record is reported as os.ErrNotExist so a caller can keep waiting for it. The path must name a regular file of at most MaxRecordSize bytes; a symlink, FIFO or device is refused without being opened.