Adding batch calculator utility and test cases for it.
This commit is contained in:
parent
ace5da6bd3
commit
b73954cd7c
2 changed files with 56 additions and 0 deletions
19
util.go
19
util.go
|
@ -99,3 +99,22 @@ func validateAuroraURL(location string) (string, error) {
|
|||
|
||||
return u.String(), nil
|
||||
}
|
||||
|
||||
func calculateCurrentBatch(updatingInstances int32, batchSizes []int32) int {
|
||||
for i, size := range batchSizes {
|
||||
updatingInstances -= size
|
||||
if updatingInstances <= 0 {
|
||||
return i
|
||||
}
|
||||
}
|
||||
|
||||
// Overflow batches
|
||||
batchCount := len(batchSizes) - 1
|
||||
lastBatchIndex := len(batchSizes) - 1
|
||||
batchCount += int(updatingInstances / batchSizes[lastBatchIndex])
|
||||
|
||||
if updatingInstances%batchSizes[lastBatchIndex] != 0 {
|
||||
batchCount++
|
||||
}
|
||||
return batchCount
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue