SelectSubGroup selects an appropriate sub-group for the given aggregate group
(group *models.Group)
| 34 | |
| 35 | // SelectSubGroup selects an appropriate sub-group for the given aggregate group |
| 36 | func (m *SubGroupManager) SelectSubGroup(group *models.Group) (string, error) { |
| 37 | if group.GroupType != "aggregate" { |
| 38 | return "", nil |
| 39 | } |
| 40 | |
| 41 | selector := m.getSelector(group) |
| 42 | if selector == nil { |
| 43 | return "", fmt.Errorf("no valid sub-groups available for aggregate group '%s'", group.Name) |
| 44 | } |
| 45 | |
| 46 | selectedName := selector.selectNext() |
| 47 | if selectedName == "" { |
| 48 | return "", fmt.Errorf("no sub-groups with active keys for aggregate group '%s'", group.Name) |
| 49 | } |
| 50 | |
| 51 | logrus.WithFields(logrus.Fields{ |
| 52 | "aggregate_group": group.Name, |
| 53 | "selected_group": selectedName, |
| 54 | }).Debug("Selected sub-group from aggregate") |
| 55 | |
| 56 | return selectedName, nil |
| 57 | } |
| 58 | |
| 59 | // RebuildSelectors rebuild all selectors based on the incoming group |
| 60 | func (m *SubGroupManager) RebuildSelectors(groups map[string]*models.Group) { |
no test coverage detected