Module: LineUp
- Defined in:
- lib/line_up.rb,
lib/line_up/job.rb,
lib/line_up/version.rb,
lib/line_up/configuration.rb,
lib/line_up/configuration.rb,
lib/line_up/string_extensions.rb
Defined Under Namespace
Modules: VERSION Classes: Configuration, Job, StringExtensions
Constant Summary collapse
- RedisNotConfiguredError =
Class.new(RuntimeError)
Class Method Summary collapse
-
.config ⇒ Object
Public: Returns the the Configuration instance.
-
.configure {|config| ... } ⇒ Object
Public: Yields the Configuration instance.
- .ensure(application, jobclass, *args) ⇒ Object
- .push(application, jobclass, *args) ⇒ Object
- .queue_length(application, jobclass) ⇒ Object
-
.reset! ⇒ Object
Public: Reset the Configuration (useful for testing).
Class Method Details
.config ⇒ Object
Public: Returns the the Configuration instance.
40 41 42 |
# File 'lib/line_up/configuration.rb', line 40 def self.config @config ||= Configuration.new end |
.configure {|config| ... } ⇒ Object
Public: Yields the Configuration instance.
46 47 48 |
# File 'lib/line_up/configuration.rb', line 46 def self.configure(&block) yield config end |
.ensure(application, jobclass, *args) ⇒ Object
16 17 18 19 20 |
# File 'lib/line_up.rb', line 16 def self.ensure(application, jobclass, *args) if queue_length(application, jobclass) == 0 push(application, jobclass, *args) end end |
.push(application, jobclass, *args) ⇒ Object
7 8 9 10 11 12 13 14 |
# File 'lib/line_up.rb', line 7 def self.push(application, jobclass, *args) redis_for application do |redis| job = Job.new jobclass, *args redis.sadd 'queues', job.queue_name redis.rpush "queue:#{job.queue_name}", job.encode end log caller, application, jobclass, *args end |
.queue_length(application, jobclass) ⇒ Object
22 23 24 25 26 27 |
# File 'lib/line_up.rb', line 22 def self.queue_length(application, jobclass) redis_for application do |r| job = Job.new jobclass return r.llen "queue:#{job.queue_name}" end end |
.reset! ⇒ Object
Public: Reset the Configuration (useful for testing)
52 53 54 |
# File 'lib/line_up/configuration.rb', line 52 def self.reset! @config = nil end |