MCPcopy Create free account
hub / github.com/cortexproject/cortex / listRulesShardingDefault

Method listRulesShardingDefault

pkg/ruler/ruler.go:927–951  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

925}
926
927func (r *Ruler) listRulesShardingDefault(ctx context.Context) (map[string]rulespb.RuleGroupList, map[string]rulespb.RuleGroupList, error) {
928 configs, err := r.store.ListAllRuleGroups(ctx)
929 if err != nil {
930 return nil, nil, err
931 }
932
933 ruleGroupCounts := make(map[string]int, len(configs))
934 ownedConfigs := make(map[string]rulespb.RuleGroupList)
935 backedUpConfigs := make(map[string]rulespb.RuleGroupList)
936 for userID, groups := range configs {
937 ruleGroupCounts[userID] = len(groups)
938 owned := r.filterRuleGroups(userID, groups, r.ring)
939 if len(owned) > 0 {
940 ownedConfigs[userID] = owned
941 }
942 if r.cfg.RulesBackupEnabled() {
943 backup := r.filterBackupRuleGroups(userID, groups, owned, r.ring)
944 if len(backup) > 0 {
945 backedUpConfigs[userID] = backup
946 }
947 }
948 }
949 r.ruleGroupMetrics.UpdateRuleGroupsInStore(ruleGroupCounts)
950 return ownedConfigs, backedUpConfigs, nil
951}
952
953func (r *Ruler) listRulesShuffleSharding(ctx context.Context) (map[string]rulespb.RuleGroupList, map[string]rulespb.RuleGroupList, error) {
954 users, err := r.store.ListAllUsers(ctx)

Callers 1

listRulesMethod · 0.95

Calls 5

filterRuleGroupsMethod · 0.95
RulesBackupEnabledMethod · 0.80
ListAllRuleGroupsMethod · 0.65

Tested by

no test coverage detected