Sha256: ae9cd5f5c45da837899f20d08d471128b76b32666bf6c2990f7ef67730b8d242

Contents?: true

Size: 747 Bytes

Versions: 5

Compression:

Stored size: 747 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

    def async(type, params={})
      @process.nest type, params
      nil
    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

5 entries across 5 versions & 1 rubygems

Version Path
asynchronic-1.1.1 lib/asynchronic/job.rb
asynchronic-1.1.0 lib/asynchronic/job.rb
asynchronic-1.0.0 lib/asynchronic/job.rb
asynchronic-0.3.1 lib/asynchronic/job.rb
asynchronic-0.3.0 lib/asynchronic/job.rb