Class: Krikri::Job

Inherits:
Object
  • Object
show all
Defined in:
lib/krikri/job.rb

Overview

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.

Direct Known Subclasses

HarvestJob, MappingJob

Class Method Summary collapse

Class Method Details

.perform(activity_id) ⇒ Object

Perform the job.



18
19
20
21
# File 'lib/krikri/job.rb', line 18

def self.perform(activity_id)
  activity = Krikri::Activity.find(activity_id)
  activity.run { |agent, activity_uri| run(agent, activity_uri) }
end

.run(_, _) ⇒ Object

This method is abstract.

run the job’s task. Implement the actual task against the agent passed in.

Parameters:

  • agent

    the agent to run the task

  • activity_uri

    the URI of the activity responsible for generating the resources. Set this to (e.g.) prov:wasGeneratedBy

Raises:

  • (NotImplementedError)


29
30
31
# File 'lib/krikri/job.rb', line 29

def self.run(_, _)
  raise NotImplementedError
end