Class: Sidekiq::Portal::JobRegistry Private

Inherits:
Object
  • Object
show all
Defined in:
lib/portal/job_registry.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Since:

  • 0.1.0

Instance Method Summary collapse

Constructor Details

#initializevoid

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 0.1.0



10
11
12
13
# File 'lib/portal/job_registry.rb', line 10

def initialize
  @jobs = {}
  @lock = Sidekiq::Portal::Lock.new
end

Instance Method Details

#each(&block) {|job| ... } ⇒ Enumerable

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

  • block (Block)

Yields:

  • (job)

Yield Parameters:

Returns:

  • (Enumerable)

Since:

  • 0.1.0



56
57
58
59
60
# File 'lib/portal/job_registry.rb', line 56

def each(&block)
  thread_safe do
    block_given? ? jobs.each_value(&block) : jobs.each_value
  end
end

#include?(job_klass) ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

  • job_klass (Class)

Returns:

  • (Boolean)

Since:

  • 0.1.0



45
46
47
# File 'lib/portal/job_registry.rb', line 45

def include?(job_klass)
  thread_safe { jobs.key?(job_klass) }
end

#register(job) ⇒ void

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.

Parameters:

Since:

  • 0.1.0



20
21
22
# File 'lib/portal/job_registry.rb', line 20

def register(job)
  thread_safe { jobs[job.klass] = job }
end

#resolve(job_klass) ⇒ Sidekiq::Portal::Job

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

  • job_klass (Class)

Returns:

Since:

  • 0.1.0



29
30
31
32
33
34
35
36
37
38
# File 'lib/portal/job_registry.rb', line 29

def resolve(job_klass)
  thread_safe do
    jobs.fetch(job_klass) do
      raise(
        Sidekiq::Portal::NonScheduledJobClassError,
        "Trying to work with non-scheduled job class \"#{job_klass}\""
      )
    end
  end
end