Sha256: a81202cb78befc5408398c0a8e882aa9e88fcf5a799d41a66dd32946ecaafb32

Contents?: true

Size: 782 Bytes

Versions: 2

Compression:

Stored size: 782 Bytes

Contents

require "sidekiq"
require "concurrent"
require_relative "merger/version"
require_relative "merger/middleware"
require_relative "merger/config"
require_relative "merger/flusher"
require_relative "merger/logging_observer"

module Sidekiq::Merger
  class << self
    attr_accessor :logger

    def start!
      interval = Sidekiq::Merger::Config.poll_interval
      observer = Sidekiq::Merger::LoggingObserver.new(logger)
      flusher = Sidekiq::Merger::Flusher.new(logger)
      task = Concurrent::TimerTask.new(
        execution_interval: interval
      ) { flusher.flush }
      task.add_observer(observer)
      logger.info(
        "[Sidekiq::Merger] Started polling merges every #{interval} seconds"
      )
      task.execute
    end
  end

  self.logger = Sidekiq.logger
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sidekiq-merger-0.0.5 lib/sidekiq/merger.rb
sidekiq-merger-0.0.4 lib/sidekiq/merger.rb