Skip to content

Commit

Permalink
Merge pull request #85 from sorah/split-ops-per-1000
Browse files Browse the repository at this point in the history
One single batch can contain 1,000 ops at max
  • Loading branch information
itkq committed Nov 27, 2019
2 parents 286f663 + 8a204ec commit 03599f6
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/roadworker/batch.rb
Expand Up @@ -79,13 +79,16 @@ def dispatch_batch!(route53, batch, i, total)
log(:info, "", :bold, dry_run: false)
end

# Slice operations to batches, per 32,000 characters in "Value"
# Slice operations to batches, per 32,000 characters in "Value" or per 1,000 operations.
def slice_operations(ops)
total_value_size = 0
total_ops = 0
ops.slice_before do |op|
total_value_size += op.value_size
if total_value_size > 32000
total_ops += 1
if total_value_size > 32000 || total_ops > 1000
total_value_size = op.value_size
total_ops = 1
true
else
false
Expand Down

0 comments on commit 03599f6

Please sign in to comment.