0.2.68
This commit is contained in:
@@ -3,6 +3,7 @@ package credits
|
||||
import (
|
||||
"context"
|
||||
"sort"
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
|
||||
@@ -39,6 +40,19 @@ const watchLimit = 500
|
||||
type TracearrSource struct {
|
||||
DB Database
|
||||
Cfg Config
|
||||
mu sync.RWMutex
|
||||
}
|
||||
|
||||
func (s *TracearrSource) Configure(cfg Config) {
|
||||
s.mu.Lock()
|
||||
s.Cfg = NormaliseConfig(cfg)
|
||||
s.mu.Unlock()
|
||||
}
|
||||
|
||||
func (s *TracearrSource) config() Config {
|
||||
s.mu.RLock()
|
||||
defer s.mu.RUnlock()
|
||||
return NormaliseConfig(s.Cfg)
|
||||
}
|
||||
|
||||
// Candidates is the whole predictive pipeline: read recent demand, group it into per-viewer
|
||||
@@ -51,10 +65,7 @@ func (s *TracearrSource) Candidates(ctx context.Context) ([]Candidate, error) {
|
||||
if s == nil || s.DB == nil {
|
||||
return nil, nil
|
||||
}
|
||||
cfg := s.Cfg
|
||||
if cfg.QueueLimit <= 0 {
|
||||
cfg = DefaultConfig()
|
||||
}
|
||||
cfg := s.config()
|
||||
now := time.Now().UTC()
|
||||
|
||||
// The decay window is the query's window too. Anything older cannot survive
|
||||
|
||||
Reference in New Issue
Block a user