refactor: remove automatic background incremental sync
Garmin's rate-limiting means every unattended sync attempt risks a ban; syncing should only ever happen when explicitly triggered via "Sync now" (POST /api/sync/run), never on an unattended timer. Removes the periodic background loop (main.go's runIncrementalSyncLoop, api.Server.RunIncrementalSyncForAllUsers), its GENIUSRUN_INCREMENTAL_SYNC_EVERY config, and store.DB.ListUsers (which existed solely to feed it). The manual "Sync now" flow (Backfill/IncrementalSync/FillPendingDetails via FullSync) is untouched.
This commit is contained in:
@@ -62,8 +62,6 @@ func main() {
|
||||
ctx, stop := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM)
|
||||
defer stop()
|
||||
|
||||
go runIncrementalSyncLoop(ctx, server, cfg.IncrementalSyncEvery)
|
||||
|
||||
httpServer := &http.Server{Addr: cfg.Addr, Handler: server.Router()}
|
||||
go func() {
|
||||
log.Printf("geniusrund listening on %s", cfg.Addr)
|
||||
@@ -80,19 +78,3 @@ func main() {
|
||||
log.Printf("http server shutdown: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
// runIncrementalSyncLoop periodically syncs new activities for every
|
||||
// provisioned user in the background so the frontend doesn't need to
|
||||
// trigger every sync manually.
|
||||
func runIncrementalSyncLoop(ctx context.Context, server *api.Server, every time.Duration) {
|
||||
ticker := time.NewTicker(every)
|
||||
defer ticker.Stop()
|
||||
for {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return
|
||||
case <-ticker.C:
|
||||
server.RunIncrementalSyncForAllUsers(ctx)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user