Sha256: 472583ea2e876f3d4201b6e73acee7b745c1726c82e4d77e71d8302165a06f60

Contents?: true

Size: 1.06 KB

Versions: 9

Compression:

Stored size: 1.06 KB

Contents

module Dynflow
  module ActiveJob
    module QueueAdapters
      module QueueMethods
        def enqueue(job)
          ::Rails.application.dynflow.world.trigger(JobWrapper, job.serialize)
        end

        def enqueue_at(job, timestamp)
          ::Rails.application.dynflow.world.delay(JobWrapper, { :start_at => Time.at(timestamp) }, job.serialize)
        end
      end

      # To use Dynflow, set the queue_adapter config to +:dynflow+.
      #
      #   Rails.application.config.active_job.queue_adapter = :dynflow
      class DynflowAdapter
        # For ActiveJob >= 5
        include QueueMethods

        # For ActiveJob <= 4
        extend QueueMethods
      end

      class JobWrapper < Dynflow::Action
        def plan(attributes)
          input[:job_class] = attributes['job_class']
          input[:job_arguments] = attributes['arguments']
          plan_self
        end

        def run
          input[:job_class].constantize.perform_now(*input[:job_arguments])
        end

        def label
          input[:job_class]
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
dynflow-0.8.37 lib/dynflow/active_job/queue_adapter.rb
dynflow-0.8.36 lib/dynflow/active_job/queue_adapter.rb
dynflow-0.8.35 lib/dynflow/active_job/queue_adapter.rb
dynflow-0.8.34 lib/dynflow/active_job/queue_adapter.rb
dynflow-0.8.33 lib/dynflow/active_job/queue_adapter.rb
dynflow-0.8.32 lib/dynflow/active_job/queue_adapter.rb
dynflow-0.8.31 lib/dynflow/active_job/queue_adapter.rb
dynflow-0.8.30 lib/dynflow/active_job/queue_adapter.rb
dynflow-0.8.29 lib/dynflow/active_job/queue_adapter.rb