Sha256: 57d49d15fe2da76088b677c035b25d118a0981cc2b6321852bcbd0ffab73905b

Contents?: true

Size: 812 Bytes

Versions: 3

Compression:

Stored size: 812 Bytes

Contents

module Sidetiq
  module Actor
    class Clock < Sidetiq::Clock
      include Sidetiq::Actor
      include Sidekiq::ExceptionHandler

      def initialize(*args, &block)
        super

        if Sidekiq.server?
          after(0) do
            debug "Sidetiq::Clock looping ..."
            loop!
          end
        end
      end

      def start!
        warn "Sidetiq::Clock#start! is deprecated. Calling it is no longer required."
      end

      private

      def loop!
        after([time { tick }, 0].max) do
          loop!
        end
      rescue StandardError => e
        handle_exception(e, context: 'Sidetiq::Clock#loop!')
        retry
      end

      def time
        start = gettime
        yield
        Sidetiq.config.resolution - (gettime.to_f - start.to_f)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
sidetiq-0.4.0.rc4 lib/sidetiq/actor/clock.rb
sidetiq-0.4.0.rc3 lib/sidetiq/actor/clock.rb
sidetiq-0.4.0.rc2 lib/sidetiq/actor/clock.rb