GetRules retrieves the running rules from this ruler and all running rulers in the ring if sharding is enabled
(ctx context.Context, rulesRequest RulesRequest)
| 1107 | // GetRules retrieves the running rules from this ruler and all running rulers in the ring if |
| 1108 | // sharding is enabled |
| 1109 | func (r *Ruler) GetRules(ctx context.Context, rulesRequest RulesRequest) (*RulesResponse, error) { |
| 1110 | userID, err := users.TenantID(ctx) |
| 1111 | if err != nil { |
| 1112 | return nil, fmt.Errorf("no user id found in context") |
| 1113 | } |
| 1114 | |
| 1115 | if r.cfg.EnableSharding { |
| 1116 | resp, err := r.getShardedRules(ctx, userID, rulesRequest) |
| 1117 | if resp == nil { |
| 1118 | return &RulesResponse{ |
| 1119 | Groups: make([]*GroupStateDesc, 0), |
| 1120 | NextToken: "", |
| 1121 | }, err |
| 1122 | } |
| 1123 | return resp, err |
| 1124 | } |
| 1125 | |
| 1126 | response, err := r.getLocalRules(userID, rulesRequest, false) |
| 1127 | return &response, err |
| 1128 | } |
| 1129 | |
| 1130 | func (r *Ruler) getLocalRules(userID string, rulesRequest RulesRequest, includeBackups bool) (RulesResponse, error) { |
| 1131 | groups := r.manager.GetRules(userID) |
nothing calls this directly
no test coverage detected