Module: Lowkiq::Worker

Defined in:
lib/lowkiq/worker.rb

Instance Method Summary collapse

Instance Method Details

#client_actionsObject



33
34
35
# File 'lib/lowkiq/worker.rb', line 33

def client_actions
  Queue::Actions.new client_queue, client_queries
end

#client_queriesObject



29
30
31
# File 'lib/lowkiq/worker.rb', line 29

def client_queries
  Queue::Queries.new Lowkiq.client_redis_pool, self.queue_name
end

#client_queueObject



25
26
27
# File 'lib/lowkiq/worker.rb', line 25

def client_queue
  Queue::Queue.new Lowkiq.client_redis_pool, self.queue_name, self.shards_count
end

#perform(payload) ⇒ Object



21
22
23
# File 'lib/lowkiq/worker.rb', line 21

def perform(payload)
  fail "not implemented"
end

#perform_async(batch) ⇒ Object



37
38
39
# File 'lib/lowkiq/worker.rb', line 37

def perform_async(batch)
  client_queue.push batch
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