Module: ActiveJobMetadata

Defined in:
lib/active_job_metadata.rb,
lib/active_job_metadata/version.rb

Defined Under Namespace

Modules: All, Lifecycle, Metadata, Timing Classes: MetadataNotFound

Constant Summary collapse

VERSION =
"0.1.0"

Class Method Summary collapse

Class Method Details

.find(job_id) ⇒ Object

Finds a job’s metadata, otherwise returns nil. Note that depending on how your store is configured, metadata may not always be available. For instance, if your store is configured to expire data after one day, then that metadata will no longer be available.



30
31
32
33
# File 'lib/active_job_metadata.rb', line 30

def self.find(job_id)
   = self.key(job_id)
  store.read()
end

.find!(job_id) ⇒ Object

Same as find, but will raise an ActiveJobMetadata::MetadataNotFound exception if the job’s metadata is not found.



23
24
25
# File 'lib/active_job_metadata.rb', line 23

def self.find!(job_id)
  find(job_id) || raise(MetadataNotFound.new("Could not find metadata: #{job_id.inspect}"))
end

.key(job_id) ⇒ Object

Generates a key for a given job id. You generally shouldn’t need this.



43
44
45
# File 'lib/active_job_metadata.rb', line 43

def self.key(job_id)
  "#{ActiveJobMetadata.prefix}-#{job_id}"
end

.write(job_id, metadata) ⇒ Object

Writes metadata for a job directly to the cache. Typically you should use accessors defined via ‘metadata` on a class. See ActiveJobMetadata::Metdadata for more information.



37
38
39
40
# File 'lib/active_job_metadata.rb', line 37

def self.write(job_id, )
   = self.key(job_id)
  store.write(, )
end