Sha256: 854603907106079eaa2c7d0a2bf55544c726318d1c9e6dbad6f0ef3d8beb1678

Contents?: true

Size: 1.24 KB

Versions: 43

Compression:

Stored size: 1.24 KB

Contents

module Krikri
  ##
  # Generic Job class that gets extended by specific types of Jobs;
  # Harvest, Enrichment, etc.
  #
  # A Job is instantiated by the queue system and #perform is invoked to run the
  # job.  The Job looks up an Activity that was created when the job was
  # enqueued and calls Activity#run, passing Job#run as a block to perform the
  # actual work. This is necessary because the Activity is designed not to care
  # about what kind of job it's running.
  #
  # @see Krikri::Activity
  # @see https://github.com/resque/resque/tree/1-x-stable
  class Job
    @queue = nil
    ##
    # Perform the job.
    def self.perform(activity_id)
      activity = Krikri::Activity.find(activity_id)
      activity.run { |agent, activity_uri| run(agent, activity_uri) }
    end

    ##
    # Run the job's task. Receieves a `Krikri::SoftwareAgent` or other object
    # responding to `#run`.
    #
    # @param agent [#run] the agent to run the task
    # @param activity_uri  the URI of the activity responsible for
    #   generating the resources. Set this to (e.g.) prov:wasGeneratedBy
    def self.run(agent, activity_uri = nil)
      return agent.run unless activity_uri && agent.method(:run).arity != 0
      agent.run(activity_uri)
    end
  end
end

Version data entries

43 entries across 43 versions & 1 rubygems

Version Path
krikri-0.15.2 lib/krikri/job.rb
krikri-0.15.1 lib/krikri/job.rb
krikri-0.15.0 lib/krikri/job.rb
krikri-0.14.0 lib/krikri/job.rb
krikri-0.13.2 lib/krikri/job.rb
krikri-0.13.1 lib/krikri/job.rb
krikri-0.13.0 lib/krikri/job.rb
krikri-0.12.4 lib/krikri/job.rb
krikri-0.12.3 lib/krikri/job.rb
krikri-0.12.1 lib/krikri/job.rb
krikri-0.12.0 lib/krikri/job.rb
krikri-0.12.0.pre.rc.1 lib/krikri/job.rb
krikri-0.11.2 lib/krikri/job.rb
krikri-0.11.1 lib/krikri/job.rb
krikri-0.11.0 lib/krikri/job.rb
krikri-0.10.1 lib/krikri/job.rb
krikri-0.10.0 lib/krikri/job.rb
krikri-0.9.0 lib/krikri/job.rb
krikri-0.8.9 lib/krikri/job.rb
krikri-0.8.8 lib/krikri/job.rb