mirror of
https://github.com/navidrome/navidrome.git
synced 2026-11-26 20:09:47 +01:00
refactor(plugins): serialize PlaylistGenerator plugin calls via work queue
Replace the timer-per-playlist + WaitGroup.Go model with a single worker goroutine processing work items from a buffered channel. This eliminates race conditions from parallel plugin calls (rate limiting risk), unsynchronized map/field access across goroutines, and overlapping discovery and refresh timers. The worker owns all mutable state (refreshTimers, discoveryTimer) exclusively, while retryInterval and refreshTimerCount use atomics for safe test observability. Also adds retry-on-failure for GetAvailablePlaylists (5 min delay) and makes MockPlaylistRepo thread-safe with sync.RWMutex.
This commit is contained in:
parent
fde4517339
commit
9c516cf601
5 changed files with 165 additions and 85 deletions
|
|
@ -192,9 +192,9 @@ func (m *Manager) startPlaylistGenerators(ctx context.Context) {
|
|||
if !hasCapability(p.capabilities, CapabilityPlaylistGenerator) {
|
||||
continue
|
||||
}
|
||||
orch := newPlaylistGeneratorOrchestrator(name, p, m.ds, ctx)
|
||||
orch := newPlaylistGeneratorOrchestrator(ctx, name, p, m.ds)
|
||||
m.playlistGenerators[name] = orch
|
||||
orch.wg.Go(func() { orch.discoverAndSync(orch.ctx) })
|
||||
go orch.run()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue