Sha256: 6c507af83c79f66ab41f986c5a2022a944befd92308e5bd7dde61bf11986725e

Contents?: true

Size: 1.24 KB

Versions: 7

Compression:

Stored size: 1.24 KB

Contents

# frozen_string_literal: true

module Ductr
  module Store
    #
    # Job's level store interactions.
    #
    module JobStore
      include JobSerializer

      # @return [String] The job key prefix
      JOB_KEY_PREFIX = "ductr:job"
      # @return [String] The job registry key
      JOB_REGISTRY_KEY = "ductr:job_registry"

      #
      # Get all known job instances.
      #
      # @return [Array<Job>] The job instances
      #
      def all_jobs
        all(JOB_REGISTRY_KEY, JOB_KEY_PREFIX)
      end

      #
      # Read all given jobs.
      #
      # @param [Array<Job>] *jobs The jobs to read
      #
      # @return [Array<Job>] The read jobs
      #
      def read_jobs(*jobs)
        read(JOB_KEY_PREFIX, *jobs)
      end

      #
      # Update the given job.
      #
      # @param [Job] job The job to update in the store
      #
      # @return [void]
      #
      def write_job(job)
        write(JOB_KEY_PREFIX, serialize_job(job))
      end

      #
      # Add the given job to the store's job registry. This method is NOT thread-safe.
      #
      # @param [Job] job The job to register
      #
      # @return [void]
      #
      def register_job(job)
        register(JOB_REGISTRY_KEY, serialize_job(job))
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
ductr-0.2.3 lib/ductr/store/job_store.rb
ductr-0.2.2 lib/ductr/store/job_store.rb
ductr-0.2.1 lib/ductr/store/job_store.rb
ductr-0.2.0 lib/ductr/store/job_store.rb
ductr-0.1.2 lib/ductr/store/job_store.rb
ductr-0.1.1 lib/ductr/store/job_store.rb
ductr-0.1.0 lib/ductr/store/job_store.rb