Skip to content

Commit 454b37a

Browse files
committed
refactor: remove named return values in replicationStrategy()
Signed-off-by: Bryan Boreham <[email protected]>
1 parent f22916b commit 454b37a

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

pkg/ring/replication_strategy.go

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ import (
1212
// - Checks there is enough ingesters for an operation to succeed.
1313
// The ingesters argument may be overwritten.
1414
func (r *Ring) replicationStrategy(ingesters []IngesterDesc, op Operation) (
15-
liveIngesters []IngesterDesc, maxFailure int, err error,
16-
) {
15+
[]IngesterDesc, int, error) {
1716
// We need a response from a quorum of ingesters, which is n/2 + 1. In the
1817
// case of a node joining/leaving, the actual replica set might be bigger
1918
// than the replication factor, so use the bigger or the two.
@@ -22,7 +21,7 @@ func (r *Ring) replicationStrategy(ingesters []IngesterDesc, op Operation) (
2221
replicationFactor = len(ingesters)
2322
}
2423
minSuccess := (replicationFactor / 2) + 1
25-
maxFailure = replicationFactor - minSuccess
24+
maxFailure := replicationFactor - minSuccess
2625

2726
// Skip those that have not heartbeated in a while. NB these are still
2827
// included in the calculation of minSuccess, so if too many failed ingesters
@@ -35,17 +34,16 @@ func (r *Ring) replicationStrategy(ingesters []IngesterDesc, op Operation) (
3534
maxFailure--
3635
}
3736
}
38-
liveIngesters = ingesters
3937

4038
// This is just a shortcut - if there are not minSuccess available ingesters,
4139
// after filtering out dead ones, don't even bother trying.
42-
if maxFailure < 0 || len(liveIngesters) < minSuccess {
43-
err = fmt.Errorf("at least %d live ingesters required, could only find %d",
44-
minSuccess, len(liveIngesters))
45-
return
40+
if maxFailure < 0 || len(ingesters) < minSuccess {
41+
err := fmt.Errorf("at least %d live ingesters required, could only find %d",
42+
minSuccess, len(ingesters))
43+
return nil, 0, err
4644
}
4745

48-
return
46+
return ingesters, maxFailure, nil
4947
}
5048

5149
// IsHealthy checks whether an ingester appears to be alive and heartbeating

0 commit comments

Comments
 (0)