Sha256: cc65d3705841150c35f6b1dfbb910f82fe693e0dce73b047aca438f5dc49df39

Contents?: true

Size: 815 Bytes

Versions: 4

Compression:

Stored size: 815 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
  LOGGER_TAG = self.name.freeze

  class << self
    attr_accessor :logger

    def create_task
      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)
      task
    end

    def configure(&block)
      yield config
    end

    def config
      @config ||= Config.new
    end
  end

  self.logger = Sidekiq.logger
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
sidekiq-merger-0.1.0 lib/sidekiq/merger.rb
sidekiq-merger-0.0.12 lib/sidekiq/merger.rb
sidekiq-merger-0.0.11 lib/sidekiq/merger.rb
sidekiq-merger-0.0.10 lib/sidekiq/merger.rb