Documentation
¶
Overview ¶
Package control is the router's local control channel: JSON lines over a 0600 unix socket. The server pushes a full route.Snapshot on connect and after every change; clients send route.Command values. The TUI and the hook are clients. Nothing from Codex requests (headers, text) is on it.
Index ¶
Constants ¶
const EnvSocket = "CODEX_ROUTER_CONTROL"
EnvSocket names the environment variable the launcher sets for the hook and the TUI.
const PublishInterval = 50 * time.Millisecond
PublishInterval is the minimum gap between pushed snapshots per client (20 per second).
const SocketMode os.FileMode = 0o600
SocketMode is the permission the socket is created with.
const SocketName = "control.sock"
SocketName is the control socket file inside the runtime dir.
Variables ¶
var ErrDisconnected = errors.New("control socket disconnected")
ErrDisconnected is returned by Send while the socket is down.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client talks to a Server. It never redials: when the socket is lost, Updates closes and Send returns ErrDisconnected, so the owner redials.
type Message ¶
type Message struct {
Type MessageType `json:"type"`
Snapshot *route.Snapshot `json:"snapshot,omitempty"`
Error string `json:"error,omitempty"`
}
Message is one server-to-client line.
type MessageType ¶
type MessageType string
MessageType tags a server-to-client line.
const ( MessageSnapshot MessageType = "snapshot" MessageAck MessageType = "ack" MessageError MessageType = "error" )
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is the control socket. It pushes snapshots to every client and applies their commands through the Handler.
func Listen ¶
Listen binds the socket at path with mode 0600, removing a stale socket file and refusing a live one or a non-socket file. The parent dir must not be accessible to group or others: the mode is set right after bind, not at bind, so the dir closes that window.