feat: wire main loop with periodic sync+scan and sync_interval config

Replace compute-only run() with an immediate sync+scan followed by a
ticker-driven periodic loop, add the sync.interval config field (default
6h) with defaults and validation, and add tests for the scheduling logic.
This commit is contained in:
2026-07-19 22:27:06 +03:00
parent dc4bdcdab0
commit 0635ca8a87
6 changed files with 313 additions and 30 deletions

View File

@@ -58,6 +58,12 @@ func (s *albumSyncer) SyncAlbums(ctx context.Context, db *database.DB) error {
return s.syncAlbums(ctx, db)
}
// NewAlbumSyncer adapts the given SyncAlbums function (typically
// navidrome.SyncAlbums) into an AlbumSyncer for injection into SyncAll.
func NewAlbumSyncer(syncAlbums func(ctx context.Context, db *database.DB) error) AlbumSyncer {
return &albumSyncer{syncAlbums: syncAlbums}
}
// SyncAll orchestrates the data pipeline for every monitored artist:
// 1. MusicBrainz artist-ID resolution — for each artist with no cached MBID,
// resolve it by name and persist it on the artist_settings row. Artists that