Sha256: 284e7bd27c9be28b74d9be44f566d3bfb904265924752d951260ef6de0ddcb5a

Contents?: true

Size: 882 Bytes

Versions: 10

Compression:

Stored size: 882 Bytes

Contents

module Asynchronic
  class Job

    def initialize(process)
      @process = process
    end

    def params
      @process.params
    end

    def result(reference)
      @process[reference].result
    end

    def self.queue(name=nil)
      name ? @queue = name : @queue
    end

    def self.enqueue(params={})
      process = Asynchronic.environment.create_process self, params
      process.enqueue
      process.id
    end

    private

    attr_reader :process

    def async(type, params={})
      process.nest type, params
      nil
    end

    def get(key)
      process.get key
    end

    def set(key, value)
      process.set key, value
    end

    def retry_when(exceptions, interval=1)
      yield
    rescue *exceptions => ex
      Asynchronic.logger.error(self.class) { "Retry for: #{ex.class} #{ex.message}" }
      sleep interval
      retry
    end

  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
asynchronic-3.0.3 lib/asynchronic/job.rb
asynchronic-3.0.2 lib/asynchronic/job.rb
asynchronic-3.0.1 lib/asynchronic/job.rb
asynchronic-3.0.0 lib/asynchronic/job.rb
asynchronic-2.0.1 lib/asynchronic/job.rb
asynchronic-2.0.0 lib/asynchronic/job.rb
asynchronic-1.6.3 lib/asynchronic/job.rb
asynchronic-1.6.2 lib/asynchronic/job.rb
asynchronic-1.6.1 lib/asynchronic/job.rb
asynchronic-1.6.0 lib/asynchronic/job.rb