Class: Allora::Backend::Memory
- Inherits:
-
Allora::Backend
- Object
- Allora::Backend
- Allora::Backend::Memory
- Defined in:
- lib/allora/backend/memory.rb
Overview
A basic, single-process backend using a Hash.
You should not run this on multiple machines on the same network.
Instance Attribute Summary
Attributes inherited from Allora::Backend
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ Memory
constructor
Initialize a new Memory backend.
- #reschedule(jobs) ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ Memory
Initialize a new Memory backend.
33 34 35 36 37 |
# File 'lib/allora/backend/memory.rb', line 33 def initialize(opts = {}) super @schedule = {} end |
Instance Method Details
#reschedule(jobs) ⇒ Object
39 40 41 42 43 44 45 46 47 48 |
# File 'lib/allora/backend/memory.rb', line 39 def reschedule(jobs) current_time = Time.now last_time = (@last_time ||= Time.now) @last_time = current_time jobs.select do |name, job| @schedule[name] ||= job.next_at(last_time) @schedule[name] < current_time && @schedule[name] = job.next_at(current_time) end end |