From 94cca1dc2f4975d1c4601710e24e34978958b31f Mon Sep 17 00:00:00 2001 From: David Ficociello Date: Thu, 16 Apr 2026 07:28:41 -0400 Subject: [PATCH] feat: switch to resilient Pulse registration via NewWithRetry MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Switches from sdk.New() to sdk.NewWithRetry() which retries registration with exponential backoff (~2 min). If Pulse is unreachable after all retries, Pilot continues in standalone mode and download clients must be configured manually via the web UI. The existing SyncDownloadClients() loop automatically picks up any download-client services (like Haul) that register with Pulse and get auto-created as download-client entries. No new discovery code is needed — the plumbing already exists. Pins pulse SDK to v0.2.0 (NewWithRetry, ServiceAPIKey, resilient heartbeat with re-registration on persistent failure). Co-Authored-By: Claude Opus 4.6 (1M context) --- go.mod | 2 +- go.sum | 4 ++-- internal/pulse/integration.go | 7 +++++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/go.mod b/go.mod index 6575c1a..7337068 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/beacon-stack/pilot go 1.25.0 require ( - github.com/beacon-stack/pulse v0.1.0 + github.com/beacon-stack/pulse v0.2.0 github.com/coder/websocket v1.8.14 github.com/danielgtaylor/huma/v2 v2.37.3 github.com/go-chi/chi/v5 v5.2.5 diff --git a/go.sum b/go.sum index 7c96feb..c7594f8 100644 --- a/go.sum +++ b/go.sum @@ -2,8 +2,8 @@ github.com/PuerkitoBio/goquery v1.12.0 h1:pAcL4g3WRXekcB9AU/y1mbKez2dbY2AajVhtkO github.com/PuerkitoBio/goquery v1.12.0/go.mod h1:802ej+gV2y7bbIhOIoPY5sT183ZW0YFofScC4q/hIpQ= github.com/andybalholm/cascadia v1.3.3 h1:AG2YHrzJIm4BZ19iwJ/DAua6Btl3IwJX+VI4kktS1LM= github.com/andybalholm/cascadia v1.3.3/go.mod h1:xNd9bqTn98Ln4DwST8/nG+H0yuB8Hmgu1YHNnWw0GeA= -github.com/beacon-stack/pulse v0.1.0 h1:PUUkyef7H07xpip/KzhVoq+uzAeh+dvGd+L1uMH6A+Q= -github.com/beacon-stack/pulse v0.1.0/go.mod h1:LyTlxljRmkoi7JOhLvtm6XnvYThcQn8eTk5l4a3Y4ko= +github.com/beacon-stack/pulse v0.2.0 h1:S0ncxtQvP2MJF5Swz81TSCDFw6lez7wXKJXuLbK1bps= +github.com/beacon-stack/pulse v0.2.0/go.mod h1:LyTlxljRmkoi7JOhLvtm6XnvYThcQn8eTk5l4a3Y4ko= github.com/coder/websocket v1.8.14 h1:9L0p0iKiNOibykf283eHkKUHHrpG7f65OE3BhhO7v9g= github.com/coder/websocket v1.8.14/go.mod h1:NX3SzP+inril6yawo5CQXx8+fk145lPDC6pumgx0mVg= github.com/danielgtaylor/huma/v2 v2.37.3 h1:6Av0Vj45Vk5lDxRVfoO2iPlEdvCvwLc7pl5nbqGOkYM= diff --git a/internal/pulse/integration.go b/internal/pulse/integration.go index cc317d9..b697e9d 100644 --- a/internal/pulse/integration.go +++ b/internal/pulse/integration.go @@ -61,7 +61,7 @@ func New(cfg config.PulseConfig, serverHost string, serverPort int, logger *slog healthURL = apiURL + "/health" } - client, err := sdk.New(sdk.Config{ + client, err := sdk.NewWithRetry(sdk.Config{ PulseURL: cfg.URL, APIKey: apiKey, ServiceName: "pilot", @@ -80,7 +80,10 @@ func New(cfg config.PulseConfig, serverHost string, serverPort int, logger *slog Logger: logger, }) if err != nil { - return nil, fmt.Errorf("pulse registration failed: %w", err) + return nil, err + } + if client == nil { + return nil, nil } return &Integration{Client: client, logger: logger}, nil