readiness

package
v0.3.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 19, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

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

View Source
const MaxRecordSize = 4 << 10

MaxRecordSize bounds the bytes Read accepts from one readiness file.

Variables

This section is empty.

Functions

func Write

func Write(path string, record Record) error

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

func Read(path string, pid int, executorID string) (Record, error)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL