Sha256: 27f5a6f0c4f1d61a8f666b139643d8742ae26f8e4131e3ae81edcea801839f30

Contents?: true

Size: 580 Bytes

Versions: 24

Compression:

Stored size: 580 Bytes

Contents

# frozen_string_literal: true

module Puppet::Scheduler
  class SplayJob < Job
    attr_reader :splay

    def initialize(run_interval, splay_limit, &block)
      @splay = calculate_splay(splay_limit)
      super(run_interval, &block)
    end

    def interval_to_next_from(time)
      if last_run
        super
      else
        (start_time + splay) - time
      end
    end

    def ready?(time)
      if last_run
        super
      else
        start_time + splay <= time
      end
    end

    private

    def calculate_splay(limit)
      rand(limit + 1)
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
puppet-8.9.0 lib/puppet/scheduler/splay_job.rb
puppet-8.9.0-x86-mingw32 lib/puppet/scheduler/splay_job.rb
puppet-8.9.0-x64-mingw32 lib/puppet/scheduler/splay_job.rb
puppet-8.9.0-universal-darwin lib/puppet/scheduler/splay_job.rb
puppet-8.8.1 lib/puppet/scheduler/splay_job.rb
puppet-8.8.1-x86-mingw32 lib/puppet/scheduler/splay_job.rb
puppet-8.8.1-x64-mingw32 lib/puppet/scheduler/splay_job.rb
puppet-8.8.1-universal-darwin lib/puppet/scheduler/splay_job.rb
puppet-8.6.0 lib/puppet/scheduler/splay_job.rb
puppet-8.6.0-x86-mingw32 lib/puppet/scheduler/splay_job.rb
puppet-8.6.0-x64-mingw32 lib/puppet/scheduler/splay_job.rb
puppet-8.6.0-universal-darwin lib/puppet/scheduler/splay_job.rb
puppet-8.5.1 lib/puppet/scheduler/splay_job.rb
puppet-8.5.1-x86-mingw32 lib/puppet/scheduler/splay_job.rb
puppet-8.5.1-x64-mingw32 lib/puppet/scheduler/splay_job.rb
puppet-8.5.1-universal-darwin lib/puppet/scheduler/splay_job.rb
puppet-8.5.0 lib/puppet/scheduler/splay_job.rb
puppet-8.5.0-x86-mingw32 lib/puppet/scheduler/splay_job.rb
puppet-8.5.0-x64-mingw32 lib/puppet/scheduler/splay_job.rb
puppet-8.5.0-universal-darwin lib/puppet/scheduler/splay_job.rb