Round-robin: rotate by channel instead of by source
Source-keyed rotation skewed toward whichever channel had the most feeds (4 of 7 sources routed to politics, so politics dominated the rotation). Channel-keyed rotation guarantees variety regardless of feed counts. Schema: round_robin_state.last_source -> last_channel, added via addColumnIfMissing so existing DBs migrate in place.
This commit is contained in:
8
main.go
8
main.go
@@ -214,9 +214,13 @@ func main() {
|
||||
slog.Info("pollers started")
|
||||
|
||||
if roundRobinMode {
|
||||
rr := scheduler.New(cfg.Sources, cfg.Posting.RoundRobin.IntervalHours, queue)
|
||||
channelNames := make([]string, 0, len(cfg.Matrix.Channels))
|
||||
for name := range cfg.Matrix.Channels {
|
||||
channelNames = append(channelNames, name)
|
||||
}
|
||||
rr := scheduler.New(channelNames, cfg.Posting.RoundRobin.IntervalHours, queue)
|
||||
if rr == nil {
|
||||
slog.Warn("round-robin enabled but no sources are enabled; nothing will post")
|
||||
slog.Warn("round-robin enabled but no channels are configured; nothing will post")
|
||||
} else {
|
||||
go rr.Start(ctx)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user