Class: Bushpig::Client
- Inherits:
-
Object
- Object
- Bushpig::Client
- Defined in:
- lib/bushpig/client.rb
Instance Attribute Summary collapse
-
#default_ttl ⇒ Object
Returns the value of attribute default_ttl.
Instance Method Summary collapse
- #default_score ⇒ Object
-
#initialize(pool, &callback) ⇒ Client
constructor
A new instance of Client.
- #redis_pool ⇒ Object
- #submit(queue, job, score: default_score, ttl: default_ttl) ⇒ Object
Constructor Details
#initialize(pool, &callback) ⇒ Client
Returns a new instance of Client.
7 8 9 10 11 |
# File 'lib/bushpig/client.rb', line 7 def initialize(pool, &callback) @pool = pool @default_ttl = nil @callback = callback end |
Instance Attribute Details
#default_ttl ⇒ Object
Returns the value of attribute default_ttl.
5 6 7 |
# File 'lib/bushpig/client.rb', line 5 def default_ttl @default_ttl end |
Instance Method Details
#default_score ⇒ Object
17 18 19 |
# File 'lib/bushpig/client.rb', line 17 def default_score Time.now.to_f end |
#redis_pool ⇒ Object
13 14 15 |
# File 'lib/bushpig/client.rb', line 13 def redis_pool @pool end |
#submit(queue, job, score: default_score, ttl: default_ttl) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/bushpig/client.rb', line 21 def submit(queue, job, score: default_score, ttl: default_ttl) new = if Bushpig.testing job.handle true else redis_pool.with do |conn| conn.set(Bushpig.job_key(job.job_key), job.job_payload, ex: ttl) conn.zadd(Bushpig.queue_key(queue), score, job.job_key) end end @callback&.call(job, new) end |