Sha256: 0c76018a060fc2b74beb8f2a07add14c8c828255b29df74fff7cc5677d6744d8
Contents?: true
Size: 579 Bytes
Versions: 20
Compression:
Stored size: 579 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
20 entries across 20 versions & 1 rubygems