Sha256: a9d09d7f435c024ce6a99df22211d6f469c1c0dee0460db8938cfaf61b5b4747

Contents?: true

Size: 1.28 KB

Versions: 3

Compression:

Stored size: 1.28 KB

Contents

module Taskinator
  module Queues

    DefaultConfig = {
      :definition_queue => :default,
      :process_queue => :default,
      :task_queue => :default
    }.freeze

    def self.create_adapter(adapter, config={})
      begin
        LoggedAdapter.new(send("create_#{adapter}_adapter", config))
      rescue NoMethodError
        raise "The queue adapter `#{adapter}` is not yet supported or it's runtime isn't loaded."
      end
    end

    class LoggedAdapter < Delegator

      attr_reader :adapter

      def initialize(adapter)
        Taskinator.logger.info("Initialized '#{adapter.class.name}' queue adapter")
        @adapter = adapter
      end

      def __getobj__
        adapter
      end

      def enqueue_create_process(definition, uuid, args)
        Taskinator.logger.info("Enqueuing process creation for #{definition}")
        adapter.enqueue_create_process(definition, uuid, args)
      end

      def enqueue_task(task)
        Taskinator.logger.info("Enqueuing task #{task}")
        adapter.enqueue_task(task)
      end

    end

  end
end

require 'taskinator/queues/active_job' if defined?(ApplicationJob)
require 'taskinator/queues/delayed_job' if defined?(Delayed)
require 'taskinator/queues/resque' if defined?(Resque)
require 'taskinator/queues/sidekiq' if defined?(Sidekiq)

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
taskinator-0.5.2 lib/taskinator/queues.rb
taskinator-0.5.1 lib/taskinator/queues.rb
taskinator-0.5.0 lib/taskinator/queues.rb