Skip to content

Commit

Permalink
[coordinator] Update ApplyCustomRuleStore interface
Browse files Browse the repository at this point in the history
  • Loading branch information
wesleyk committed Dec 10, 2020
1 parent b7ea2e7 commit 7fd8357
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/cmd/services/m3coordinator/downsample/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ var (
)

// CustomRuleStoreFn is a function to swap the backend used for the rule stores.
type CustomRuleStoreFn func(kv.Store) (kv.Store, error)
type CustomRuleStoreFn func(clusterclient.Client) (kv.TxnStore, error)

// DownsamplerOptions is a set of required downsampler options.
type DownsamplerOptions struct {
Expand Down
19 changes: 12 additions & 7 deletions src/query/server/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import (
"github.com/m3db/m3/src/aggregator/server"
clusterclient "github.com/m3db/m3/src/cluster/client"
etcdclient "github.com/m3db/m3/src/cluster/client/etcd"
"github.com/m3db/m3/src/cluster/kv"
"github.com/m3db/m3/src/cmd/services/m3aggregator/serve"
"github.com/m3db/m3/src/cmd/services/m3coordinator/downsample"
"github.com/m3db/m3/src/cmd/services/m3coordinator/ingest"
Expand Down Expand Up @@ -742,13 +743,17 @@ func newDownsampler(
"must set this config for downsampler")
}

kvStore, err := clusterManagementClient.KV()
if err != nil {
return nil, errors.Wrap(err, "unable to create KV store from the "+
"cluster management config client")
}
if applyCustomRuleStore != nil {
kvStore, err = applyCustomRuleStore(kvStore)
var kvStore kv.Store
var err error

if applyCustomRuleStore == nil {
kvStore, err = clusterManagementClient.KV()
if err != nil {
return nil, errors.Wrap(err, "unable to create KV store from the "+
"cluster management config client")
}
} else {
kvStore, err = applyCustomRuleStore(clusterManagementClient)
if err != nil {
return nil, errors.Wrap(err, "unable to apply custom rule store")
}
Expand Down

0 comments on commit 7fd8357

Please sign in to comment.