Module: Jets::Cfn::Builders::ParentBuilder::Stagger
- Included in:
- Jets::Cfn::Builders::ParentBuilder
- Defined in:
- lib/jets/cfn/builders/parent_builder/stagger.rb
Instance Method Summary collapse
- #add_stagger(resource) ⇒ Object
- #stagger_batch_size ⇒ Object
-
#stagger_enabled ⇒ Object
for spec-ing.
Instance Method Details
#add_stagger(resource) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/jets/cfn/builders/parent_builder/stagger.rb', line 3 def add_stagger(resource) batch_size = stagger_batch_size # shorter convenience variable return if !stagger_enabled || batch_size.nil? || batch_size == 0 # initialize all here to keep logic together @previous_stacks ||= [] @added_count ||= 0 if @previous_stacks.size >= batch_size at_boundary = @added_count % batch_size == 0 if at_boundary @left = @added_count - batch_size @right = @left + batch_size - 1 end previous_stack_batch = @previous_stacks[@left..@right] resource.add_stagger_depends_on(previous_stack_batch) end @added_count += 1 @previous_stacks << resource end |