feat(agent): hybrid SSE downlink with long-poll fallback
Replace the bare long-poll wake listener with a hybrid server→agent
downlink that consumes the new GET /api/internal/agent/events SSE stream
first and falls back to the long-poll wake when SSE is unavailable or
silently buffered. Resurrects the SSE client retired with WebRTC
(signal_client.go) as events_client.go — a bounded-scanner reader
(256 KiB line / 1 MiB event) that surfaces heartbeat comments as ping
events so the consumer can detect liveness.
runDownlink dispatches on the new [daemon] downlink config:
- auto (default): SSE-first; after maxSSEFailures dead/buffered attempts
fall back to long-poll for 5 min, then re-probe SSE.
- sse: SSE only, no fallback (known-good networks / testing).
- poll: the pre-0.14 long-poll wake only.
A stream is "healthy" only if it delivers a frame within livenessTimeout
(40s vs the server's 15s heartbeat). Crucially the liveness-timeout branch
returns UNHEALTHY even if an earlier frame arrived: a proxy that flushes
the connect preamble (one ping) then stalls must not pin the agent to SSE
forever — that's the partial-buffering case the fallback exists for.
event: command applies typed controls via the same OnControl callback
/agent/sync uses (idempotent); event: sync triggers an immediate sync;
ping is liveness-only. OpenEventStream rides MirrorPool failover for the
initial connect; mid-stream drops close the channel and the loop reopens.
Bump 0.14.0.
This commit is contained in:
parent
96b23ed051
commit
1052529ca2
8 changed files with 827 additions and 7 deletions
|
|
@ -179,6 +179,7 @@ func runDaemonStart() error {
|
|||
HWEncoders: hwDiag.Encoders,
|
||||
HWDevices: hwDiag.Devices,
|
||||
AutoUpgrade: cfg.Daemon.AutoUpgradeEnabled(),
|
||||
Downlink: cfg.Daemon.Downlink,
|
||||
}
|
||||
|
||||
// Create HTTP client with mirror failover so a `.com` block-out rolls
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue