Sha256: c748b6cd5d228ae8d93d54dfbbad91204f9de0807359eeb7f79982294b85fbdc

Contents?: true

Size: 1.54 KB

Versions: 19

Compression:

Stored size: 1.54 KB

Contents

module Taskinator
  module Queues

    # https://github.com/mperham/sidekiq

    def self.create_sidekiq_adapter(config={})
      SidekiqAdapter.new(config)
    end

    class SidekiqAdapter
      def initialize(config={})
        @config = Taskinator::Queues::DefaultConfig.merge(config)
      end

      def enqueue_create_process(definition, uuid, args)
        queue = definition.queue || @config[:definition_queue]
        CreateProcessWorker.client_push('class' => CreateProcessWorker, 'args' => [definition.name, uuid, Taskinator::Persistence.serialize(args)], 'queue' => queue)
      end

      def enqueue_process(process)
        queue = process.queue || @config[:process_queue]
        TaskWorker.client_push('class' => ProcessWorker, 'args' => [process.uuid], 'queue' => queue)
      end

      def enqueue_task(task)
        queue = task.queue || @config[:task_queue]
        TaskWorker.client_push('class' => TaskWorker, 'args' => [task.uuid], 'queue' => queue)
      end

      class CreateProcessWorker
        include ::Sidekiq::Worker

        def perform(definition_name, uuid, args)
          Taskinator::CreateProcessWorker.new(definition_name, uuid, args).perform
        end
      end

      class ProcessWorker
        include ::Sidekiq::Worker

        def perform(process_uuid)
          Taskinator::ProcessWorker.new(process_uuid).perform
        end
      end

      class TaskWorker
        include ::Sidekiq::Worker

        def perform(task_uuid)
          Taskinator::TaskWorker.new(task_uuid).perform
        end
      end

    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
taskinator-0.4.7 lib/taskinator/queues/sidekiq.rb
taskinator-0.4.6 lib/taskinator/queues/sidekiq.rb
taskinator-0.4.5 lib/taskinator/queues/sidekiq.rb
taskinator-0.4.4 lib/taskinator/queues/sidekiq.rb
taskinator-0.4.3 lib/taskinator/queues/sidekiq.rb
taskinator-0.4.2 lib/taskinator/queues/sidekiq.rb
taskinator-0.4.1 lib/taskinator/queues/sidekiq.rb
taskinator-0.4.0 lib/taskinator/queues/sidekiq.rb
taskinator-0.3.16 lib/taskinator/queues/sidekiq.rb
taskinator-0.3.15 lib/taskinator/queues/sidekiq.rb
taskinator-0.3.14 lib/taskinator/queues/sidekiq.rb
taskinator-0.3.13 lib/taskinator/queues/sidekiq.rb
taskinator-0.3.12 lib/taskinator/queues/sidekiq.rb
taskinator-0.3.11 lib/taskinator/queues/sidekiq.rb
taskinator-0.3.10 lib/taskinator/queues/sidekiq.rb
taskinator-0.3.9 lib/taskinator/queues/sidekiq.rb
taskinator-0.3.7 lib/taskinator/queues/sidekiq.rb
taskinator-0.3.6 lib/taskinator/queues/sidekiq.rb
taskinator-0.3.5 lib/taskinator/queues/sidekiq.rb