feat(sync): replace WS+DO transport with unified HTTP sync
Replace the WebSocket + Cloudflare Durable Object architecture with a single POST /sync endpoint. The CLI now operates autonomously with local state (tasks.json) and syncs bidirectionally via adaptive-interval HTTP polling (3s watching, 60s idle). - Remove transport_ws, transport_hybrid, transport_http (~2,600 lines) - Add SyncClient with adaptive interval loop - Add LocalState for CLI-side task persistence - Add TaskStateFromUpdate() helper (DRY) - Extract finalize() to deduplicate processTask/processTaskRetry - Consolidate shortID() into agent.ShortID (was in 3 packages) - Wire GetActiveCount so `unarr status` shows active tasks - Remove poll_interval, heartbeat_interval, ws_url from config - Simplify ProgressReporter (sync replaces direct HTTP reporting)
This commit is contained in:
parent
2398707cc1
commit
5d4a67c7a2
26 changed files with 1320 additions and 3400 deletions
|
|
@ -7,7 +7,6 @@ import (
|
|||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"github.com/torrentclaw/unarr/internal/agent"
|
||||
"github.com/torrentclaw/unarr/internal/config"
|
||||
|
|
@ -19,7 +18,8 @@ type ReloadableConfig struct {
|
|||
}
|
||||
|
||||
// startReloadWatcher listens for SIGUSR1 and reloads config.
|
||||
// Only intervals are hot-reloadable (speeds require torrent client restart).
|
||||
// With the sync-based architecture, intervals are fixed (3s watching, 60s idle).
|
||||
// Hot-reload now mainly serves as a signal to re-read config for future settings.
|
||||
func startReloadWatcher(rc *ReloadableConfig) {
|
||||
sigCh := make(chan os.Signal, 1)
|
||||
signal.Notify(sigCh, syscall.SIGUSR1)
|
||||
|
|
@ -28,24 +28,11 @@ func startReloadWatcher(rc *ReloadableConfig) {
|
|||
for range sigCh {
|
||||
log.Println("Received SIGUSR1, reloading config...")
|
||||
|
||||
cfg, err := config.Load("")
|
||||
_, err := config.Load("")
|
||||
if err != nil {
|
||||
log.Printf("Config reload failed: %v", err)
|
||||
continue
|
||||
}
|
||||
cfg.ApplyEnvOverrides()
|
||||
|
||||
// Update poll interval
|
||||
if d, _ := time.ParseDuration(cfg.Daemon.PollInterval); d > 0 && rc.Daemon.PollTicker != nil {
|
||||
rc.Daemon.PollTicker.Reset(d)
|
||||
log.Printf(" Poll interval: %s", d)
|
||||
}
|
||||
|
||||
// Update heartbeat interval
|
||||
if d, _ := time.ParseDuration(cfg.Daemon.HeartbeatInterval); d > 0 && rc.Daemon.HeartbeatTicker != nil {
|
||||
rc.Daemon.HeartbeatTicker.Reset(d)
|
||||
log.Printf(" Heartbeat interval: %s", d)
|
||||
}
|
||||
|
||||
log.Println("Config reloaded successfully")
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue