Class: BackgroundQueue::ServerLib::JobRegistry
- Inherits:
-
Object
- Object
- BackgroundQueue::ServerLib::JobRegistry
- Defined in:
- lib/background_queue/server_lib/job_registry.rb
Overview
keep track of jobs, even after they have finished. this allows us to query the status of the job after its finished. It is used to get the status of the job
Instance Method Summary collapse
- #get_job(id) ⇒ Object
-
#initialize(size = 1000) ⇒ JobRegistry
constructor
A new instance of JobRegistry.
- #register(job) ⇒ Object
Constructor Details
#initialize(size = 1000) ⇒ JobRegistry
Returns a new instance of JobRegistry.
6 7 8 9 10 |
# File 'lib/background_queue/server_lib/job_registry.rb', line 6 def initialize(size = 1000) @lru = Cache::LRU.new(:max_elements=>size) @mutex = Mutex.new end |
Instance Method Details
#get_job(id) ⇒ Object
18 19 20 21 22 |
# File 'lib/background_queue/server_lib/job_registry.rb', line 18 def get_job(id) @mutex.synchronize { @lru[id] } end |
#register(job) ⇒ Object
12 13 14 15 16 |
# File 'lib/background_queue/server_lib/job_registry.rb', line 12 def register(job) @mutex.synchronize { @lru[job.id] = job } end |