Expand description
Local-daemon auto-detection.
Every gRPC-using verb in the CLI checks this first. When the per-repo
.heddle/sockets/grpc.sock exists and the pidfile points at a live
process, callers can route their RPC over the UDS instead of opening
an in-process [GrpcLocalService]. The latency win matters for tight
agent loops.
Three layers:
detect_local_daemon— file-stat probe (pidfile + liveness viakill(pid, 0)+ same-executable identity). Cheap, syscall-only, used as the cheap negative case (“no daemon, fall through to in-process”).detect_local_daemon_with_connect_probe— same as (1) but actually opens aUnixStreamand checks kernel-reported peer credentials to confirm the listener is owned by our uid. Catches the “stale socket file with a live unrelated PID” race.connect_local_daemon_channel— full path: build a tonictonic::transport::Channelover the UDS, run the gRPCHealth.Checkhandshake, and cache the working channel for the rest of the process. This is what the read-shaped CLI verbs route through.
All three caches are keyed by canonical heddle-dir path, so a CLI invocation that touches one repo pays the probe cost exactly once.
Structs§
- Local
Daemon Channel - Connect-and-handshake outcome for
connect_local_daemon_channel. - Local
Daemon Probe - UdsTarget
- A reachable local daemon — the path of the UDS socket the caller
can connect to. Returned by
detect_local_daemonwhen the probe reportsRunning.
Enums§
Functions§
- connect_
local_ daemon_ channel - Build a tonic
tonic::transport::Channelover the per-repo UDS, perform the gRPCHealth.Checkhandshake, and return both alongside theUdsTarget. - detect_
local_ daemon - Run the probe and, when the daemon is
Running, return the UDS target a tonic client can dial. Cached for the process lifetime so hot agent loops don’t pay two stat-syscalls per RPC. - detect_
local_ daemon_ with_ connect_ probe - Stronger variant of
detect_local_daemon— runs the file-stat probe, then attempts a UDS connect to confirm the daemon is actually accepting connections (not just a stale pidfile that happens to point at a live unrelated process). - probe
- Probe the per-repo daemon directory. Cheap (two file stats,
kill(pid, 0), and same-executable identity for live pids).