AddShards initializes or updates the shard information in the tracker. This should be called when job metadata arrives from the sharder. Returns the current completedThroughSeconds value.
(shards []Shard)
| 41 | // This should be called when job metadata arrives from the sharder. |
| 42 | // Returns the current completedThroughSeconds value. |
| 43 | func (c *CompletionTracker) AddShards(shards []Shard) uint32 { |
| 44 | if len(shards) == 0 { |
| 45 | return c.completedThroughSeconds |
| 46 | } |
| 47 | |
| 48 | c.shards = shards |
| 49 | |
| 50 | // grow foundResponses to match while keeping the existing values |
| 51 | if len(c.shards) > len(c.foundResponses) { |
| 52 | temp := make([]int, len(c.shards)) |
| 53 | copy(temp, c.foundResponses) |
| 54 | c.foundResponses = temp |
| 55 | } |
| 56 | |
| 57 | c.incrementCurShardIfComplete() |
| 58 | |
| 59 | return c.completedThroughSeconds |
| 60 | } |
| 61 | |
| 62 | // AddShardIdx records that a response has been received for the given shard index. |
| 63 | // This should be called each time a job completes for a particular shard. |