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
|
|
@ -151,6 +151,11 @@ type DaemonConfig struct {
|
|||
// logs "new version available" and the operator must run `unarr update`
|
||||
// manually. Default: true. Available since unarr 0.9.6.
|
||||
AutoUpgrade *bool `toml:"auto_upgrade"`
|
||||
// Downlink selects the server→agent realtime transport. "auto" (default)
|
||||
// uses an SSE push connection with the long-poll wake as a buffering-tolerant
|
||||
// fallback; "sse" forces SSE only (no fallback); "poll" forces the pre-0.14
|
||||
// long-poll wake only. Empty = "auto". Available since unarr 0.14.0.
|
||||
Downlink string `toml:"downlink"`
|
||||
}
|
||||
|
||||
// AutoUpgradeEnabled returns the resolved AutoUpgrade flag — defaults to true
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue