@@ -14,7 +14,6 @@ import (
1414
1515 "github.com/weaveworks/common/instrument"
1616 "github.com/weaveworks/cortex/pkg/configs"
17- configs_client "github.com/weaveworks/cortex/pkg/configs/client"
1817 "github.com/weaveworks/cortex/pkg/util"
1918)
2019
@@ -79,7 +78,7 @@ func (w workItem) String() string {
7978}
8079
8180type scheduler struct {
82- configsAPI configs_client. RulesAPI
81+ rulesAPI RulesAPI
8382 evaluationInterval time.Duration // how often we re-evaluate each rule set
8483 q * SchedulingQueue
8584
@@ -94,9 +93,9 @@ type scheduler struct {
9493}
9594
9695// newScheduler makes a new scheduler.
97- func newScheduler (configsAPI configs_client. RulesAPI , evaluationInterval , pollInterval time.Duration ) scheduler {
96+ func newScheduler (rulesAPI RulesAPI , evaluationInterval , pollInterval time.Duration ) scheduler {
9897 return scheduler {
99- configsAPI : configsAPI ,
98+ rulesAPI : rulesAPI ,
10099 evaluationInterval : evaluationInterval ,
101100 pollInterval : pollInterval ,
102101 q : NewSchedulingQueue (clockwork .NewRealClock ()),
@@ -137,7 +136,7 @@ func (s *scheduler) Stop() {
137136
138137// Load the full set of configurations from the server, retrying with backoff
139138// until we can get them.
140- func (s * scheduler ) loadAllConfigs () map [string ]configs.View {
139+ func (s * scheduler ) loadAllConfigs () map [string ]configs.VersionedRulesConfig {
141140 backoff := util .NewBackoff (context .Background (), backoffConfig )
142141 for {
143142 cfgs , err := s .poll ()
@@ -160,31 +159,31 @@ func (s *scheduler) updateConfigs(now time.Time) error {
160159}
161160
162161// poll the configuration server. Not re-entrant.
163- func (s * scheduler ) poll () (map [string ]configs.View , error ) {
162+ func (s * scheduler ) poll () (map [string ]configs.VersionedRulesConfig , error ) {
164163 s .Lock ()
165164 configID := s .latestConfig
166165 s .Unlock ()
167- var cfgs * configs_client. ConfigsResponse
166+ var cfgs map [ string ]configs. VersionedRulesConfig
168167 err := instrument .TimeRequestHistogram (context .Background (), "Configs.GetConfigs" , configsRequestDuration , func (_ context.Context ) error {
169168 var err error
170- cfgs , err = s .configsAPI .GetConfigs (configID )
169+ cfgs , err = s .rulesAPI .GetConfigs (configID )
171170 return err
172171 })
173172 if err != nil {
174173 level .Warn (util .Logger ).Log ("msg" , "scheduler: configs server poll failed" , "err" , err )
175174 return nil , err
176175 }
177176 s .Lock ()
178- s .latestConfig = cfgs . GetLatestConfigID ( )
177+ s .latestConfig = getLatestConfigID ( cfgs , configID )
179178 s .Unlock ()
180- return cfgs . Configs , nil
179+ return cfgs , nil
181180}
182181
183- func (s * scheduler ) addNewConfigs (now time.Time , cfgs map [string ]configs.View ) {
182+ func (s * scheduler ) addNewConfigs (now time.Time , cfgs map [string ]configs.VersionedRulesConfig ) {
184183 // TODO: instrument how many configs we have, both valid & invalid.
185184 level .Debug (util .Logger ).Log ("msg" , "adding configurations" , "num_configs" , len (cfgs ))
186185 for userID , config := range cfgs {
187- rules , err := configs_client . RulesFromConfig ( config .Config )
186+ rules , err := config .Config . Parse ( )
188187 if err != nil {
189188 // XXX: This means that if a user has a working configuration and
190189 // they submit a broken one, we'll keep processing the last known
0 commit comments