Module: Lowkiq::Worker
- Defined in:
- lib/lowkiq/worker.rb
Instance Attribute Summary collapse
-
#batch_size ⇒ Object
Returns the value of attribute batch_size.
-
#max_retry_count ⇒ Object
Returns the value of attribute max_retry_count.
-
#queue_name ⇒ Object
Returns the value of attribute queue_name.
-
#shards_count ⇒ Object
Returns the value of attribute shards_count.
Class Method Summary collapse
Instance Method Summary collapse
- #client_actions ⇒ Object
- #client_queries ⇒ Object
- #client_queue ⇒ Object
- #perform(payload) ⇒ Object
- #perform_async(batch) ⇒ Object
- #retries_exhausted(batch) ⇒ Object
-
#retry_in(retry_count) ⇒ Object
i.e.
Instance Attribute Details
#batch_size ⇒ Object
Returns the value of attribute batch_size.
3 4 5 |
# File 'lib/lowkiq/worker.rb', line 3 def batch_size @batch_size end |
#max_retry_count ⇒ Object
Returns the value of attribute max_retry_count.
3 4 5 |
# File 'lib/lowkiq/worker.rb', line 3 def max_retry_count @max_retry_count end |
#queue_name ⇒ Object
Returns the value of attribute queue_name.
3 4 5 |
# File 'lib/lowkiq/worker.rb', line 3 def queue_name @queue_name end |
#shards_count ⇒ Object
Returns the value of attribute shards_count.
3 4 5 |
# File 'lib/lowkiq/worker.rb', line 3 def shards_count @shards_count end |
Class Method Details
.extended(mod) ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/lowkiq/worker.rb', line 8 def self.extended(mod) super mod.shards_count = 5 mod.batch_size = 1 mod.max_retry_count = 25 mod.queue_name = mod.name end |
Instance Method Details
#client_actions ⇒ Object
37 38 39 |
# File 'lib/lowkiq/worker.rb', line 37 def client_actions Queue::Actions.new client_queue, client_queries end |
#client_queries ⇒ Object
33 34 35 |
# File 'lib/lowkiq/worker.rb', line 33 def client_queries Queue::Queries.new Lowkiq.client_redis_pool, self.queue_name end |
#client_queue ⇒ Object
29 30 31 |
# File 'lib/lowkiq/worker.rb', line 29 def client_queue Queue::Queue.new Lowkiq.client_redis_pool, self.queue_name, self.shards_count end |
#perform(payload) ⇒ Object
25 26 27 |
# File 'lib/lowkiq/worker.rb', line 25 def perform(payload) fail "not implemented" end |
#perform_async(batch) ⇒ Object
41 42 43 |
# File 'lib/lowkiq/worker.rb', line 41 def perform_async(batch) Lowkiq.client_wrapper.call(self, batch) {client_queue.push batch} end |
#retries_exhausted(batch) ⇒ Object
21 22 23 |
# File 'lib/lowkiq/worker.rb', line 21 def retries_exhausted(batch) # no-op end |
#retry_in(retry_count) ⇒ Object
i.e. 15, 16, 31, 96, 271, … seconds + a random amount of time
17 18 19 |
# File 'lib/lowkiq/worker.rb', line 17 def retry_in(retry_count) (retry_count ** 4) + 15 + (rand(30) * (retry_count + 1)) end |