Module: Ductr::Store::JobStore

Includes:
JobSerializer
Included in:
Ductr::Store
Defined in:
lib/ductr/store/job_store.rb

Overview

Job’s level store interactions.

Constant Summary collapse

JOB_KEY_PREFIX =

Returns The job key prefix.

Returns:

  • (String)

    The job key prefix

"ductr:job"
JOB_REGISTRY_KEY =

Returns The job registry key.

Returns:

  • (String)

    The job registry key

"ductr:job_registry"

Instance Method Summary collapse

Methods included from JobSerializer

#serialize_job

Instance Method Details

#all_jobsArray<Job>

Get all known job instances.

Returns:

  • (Array<Job>)

    The job instances



21
22
23
# File 'lib/ductr/store/job_store.rb', line 21

def all_jobs
  all(JOB_REGISTRY_KEY, JOB_KEY_PREFIX)
end

#read_jobs(*jobs) ⇒ Array<Job>

Read all given jobs.

Parameters:

  • *jobs (Array<Job>)

    The jobs to read

Returns:

  • (Array<Job>)

    The read jobs



32
33
34
# File 'lib/ductr/store/job_store.rb', line 32

def read_jobs(*jobs)
  read(JOB_KEY_PREFIX, *jobs)
end

#register_job(job) ⇒ void

This method returns an undefined value.

Add the given job to the store’s job registry. This method is NOT thread-safe.

Parameters:

  • job (Job)

    The job to register



54
55
56
# File 'lib/ductr/store/job_store.rb', line 54

def register_job(job)
  register(JOB_REGISTRY_KEY, serialize_job(job))
end

#write_job(job) ⇒ void

This method returns an undefined value.

Update the given job.

Parameters:

  • job (Job)

    The job to update in the store



43
44
45
# File 'lib/ductr/store/job_store.rb', line 43

def write_job(job)
  write(JOB_KEY_PREFIX, serialize_job(job))
end