docs/local-domains-domainsd-cpp-spec.md
This document defines the native local-domains path for Flow.
Goal:
*.localhost names,This is an incremental migration path.
Phase 1 (implemented now):
f domains --engine native ...domainsd-cpp) built by Flow with clang++~/.config/flow/local-domains/routes.json503)504 for upstream connect timeout)/_flow/domains/health:80 bind without DockerPhase 2:
Phase 3:
.localhost conventionsFlow CLI remains the control plane:
f domains list
f domains add app.localhost 127.0.0.1:3000
f domains rm app.localhost
f domains --engine native up
f domains --engine native down
f domains --engine native doctor
Engine selection:
--engine docker|nativeFLOW_DOMAINS_ENGINE=nativedockerCurrent state remains:
~/.config/flow/local-domains/routes.jsonNative runtime artifacts:
~/.config/flow/local-domains/domainsd.pid~/.config/flow/local-domains/domainsd.log~/.config/flow/local-domains/domainsd-cpp/Library/LaunchDaemons/dev.flow.domainsd.plistNative tuning env vars (read by f domains --engine native up and passed to daemon):
FLOW_DOMAINS_NATIVE_MAX_ACTIVE_CLIENTS (default 128)FLOW_DOMAINS_NATIVE_UPSTREAM_CONNECT_TIMEOUT_MS (default 10000)FLOW_DOMAINS_NATIVE_UPSTREAM_IO_TIMEOUT_MS (default 15000)FLOW_DOMAINS_NATIVE_CLIENT_IO_TIMEOUT_MS (default 30000)FLOW_DOMAINS_NATIVE_POOL_MAX_IDLE_PER_KEY (default 8)FLOW_DOMAINS_NATIVE_POOL_MAX_IDLE_TOTAL (default 256)FLOW_DOMAINS_NATIVE_POOL_IDLE_TIMEOUT_MS (default 15000)FLOW_DOMAINS_NATIVE_POOL_MAX_AGE_MS (default 120000)Listen address:
127.0.0.1:80macOS launchd mode:
--launchd-socket domainsd (socket inherited from launchd)Routing:
Host header (strip :port)host -> target from routes.jsonhost:port)Special endpoint:
GET /_flow/domains/healthX-Flow-Domainsd: 1Errors:
404 when host route is not configured502 on upstream connection/forward failures503 when proxy is saturated and sheds overload504 on upstream connect timeout400 for malformed HTTP requestsf domains doctor should always show effective owner on port 80.f domains add myflow.localhost 127.0.0.1:3000
sudo ./tools/domainsd-cpp/install-macos-launchd.sh # macOS when direct bind is denied
f domains --engine native up
f domains --engine native doctor
curl -H 'Host: myflow.localhost' http://127.0.0.1/
sudo ./tools/domainsd-cpp/uninstall-macos-launchd.sh # optional teardown