Sha256: ebc40ce9cef6c83786eb5f27e17e2485c6795e2d7c363edb5ac772245d9fc746

Contents?: true

Size: 933 Bytes

Versions: 15

Compression:

Stored size: 933 Bytes

Contents

class Jets::Cfn::Builder::Parent
  module Stagger
    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

    def stagger_batch_size
      Jets.config.deploy.stagger.batch_size
    end

    # for spec-ing
    def stagger_enabled
      Jets.config.deploy.stagger.enabled
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
jets-5.0.13 lib/jets/cfn/builder/parent/stagger.rb
jets-5.0.12 lib/jets/cfn/builder/parent/stagger.rb
jets-5.0.11 lib/jets/cfn/builder/parent/stagger.rb
jets-5.0.10 lib/jets/cfn/builder/parent/stagger.rb
jets-5.0.9 lib/jets/cfn/builder/parent/stagger.rb
jets-5.0.8 lib/jets/cfn/builder/parent/stagger.rb
jets-5.0.7 lib/jets/cfn/builder/parent/stagger.rb
jets-5.0.6 lib/jets/cfn/builder/parent/stagger.rb
jets-5.0.5 lib/jets/cfn/builder/parent/stagger.rb
jets-5.0.4 lib/jets/cfn/builder/parent/stagger.rb
jets-5.0.3 lib/jets/cfn/builder/parent/stagger.rb
jets-5.0.2 lib/jets/cfn/builder/parent/stagger.rb
jets-5.0.1 lib/jets/cfn/builder/parent/stagger.rb
jets-5.0.0 lib/jets/cfn/builder/parent/stagger.rb
jets-5.0.0.beta1 lib/jets/cfn/builder/parent/stagger.rb