Class: Jiggler::AtMostOnce::Fetcher

Inherits:
BaseFetcher show all
Defined in:
lib/jiggler/at_most_once/fetcher.rb

Defined Under Namespace

Classes: CurrentJob

Constant Summary collapse

TIMEOUT =

2 seconds of waiting for brpop

2.0

Instance Attribute Summary

Attributes inherited from BaseFetcher

#collection, #config

Instance Method Summary collapse

Methods inherited from BaseFetcher

#initialize

Methods included from Support::Helper

#log_error, #log_error_short, #logger, #safe_async, #scan_all, #tid

Constructor Details

This class inherits a constructor from Jiggler::BaseFetcher

Instance Method Details

#fetchObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/jiggler/at_most_once/fetcher.rb', line 14

def fetch
  return :done if @done

  q, args = config.with_sync_redis do |conn|
    conn.blocking_call(false, 'BRPOP', *config.sorted_lists, TIMEOUT)
  end

  if @done
    requeue(q, args) unless q.nil?
    return :done
  end

  job(q, args) unless q.nil?
end

#startObject



10
11
12
# File 'lib/jiggler/at_most_once/fetcher.rb', line 10

def start
  # noop, we just block directly during the fetch
end

#suspendObject



29
30
31
# File 'lib/jiggler/at_most_once/fetcher.rb', line 29

def suspend
  @done = true
end