| 121 | } |
| 122 | |
| 123 | func (t *zoneAwareResultTracker) done(instance *InstanceDesc, result any, err error) { |
| 124 | if err != nil { |
| 125 | t.failuresByZone[instance.Zone]++ |
| 126 | t.errors = append(t.errors, fmt.Errorf("(%s, %s) %w", instance.GetAddr(), instance.GetZone(), err)) |
| 127 | } else { |
| 128 | if _, ok := t.resultsPerZone[instance.Zone]; !ok { |
| 129 | // If it is the first result in the zone, then total number of instances |
| 130 | // in this zone should be number of waiting required. |
| 131 | t.resultsPerZone[instance.Zone] = make([]any, 0, t.waitingByZone[instance.Zone]) |
| 132 | } |
| 133 | t.resultsPerZone[instance.Zone] = append(t.resultsPerZone[instance.Zone], result) |
| 134 | } |
| 135 | |
| 136 | t.waitingByZone[instance.Zone]-- |
| 137 | t.doneCount++ |
| 138 | } |
| 139 | |
| 140 | func (t *zoneAwareResultTracker) finished() bool { |
| 141 | return t.doneCount == t.numInstances |