Class: Fairway::Sidekiq::Fetch
- Inherits:
-
Object
- Object
- Fairway::Sidekiq::Fetch
- Defined in:
- lib/fairway/sidekiq/fetch.rb
Defined Under Namespace
Classes: Fetches
Instance Method Summary collapse
- #fetch_order ⇒ Object
- #fetches ⇒ Object
-
#initialize {|@fetches = Fetches.new| ... } ⇒ Fetch
constructor
A new instance of Fetch.
- #new(options) ⇒ Object
- #retrieve_work(options = {}) ⇒ Object
Constructor Details
Instance Method Details
#fetch_order ⇒ Object
36 37 38 |
# File 'lib/fairway/sidekiq/fetch.rb', line 36 def fetch_order fetches.shuffle.uniq end |
#fetches ⇒ Object
32 33 34 |
# File 'lib/fairway/sidekiq/fetch.rb', line 32 def fetches @fetches.list end |
#new(options) ⇒ Object
28 29 30 |
# File 'lib/fairway/sidekiq/fetch.rb', line 28 def new() self end |
#retrieve_work(options = {}) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/fairway/sidekiq/fetch.rb', line 40 def retrieve_work( = {}) = { blocking: true }.merge() ::Sidekiq.logger.debug "#{self.class.name}#retrieve_work" fetch_order.each do |fetch| work = fetch.retrieve_work(blocking: false) if work ::Sidekiq.logger.debug "#{self.class.name}#retrieve_work got work" return work end end ::Sidekiq.logger.debug "#{self.class.name}#retrieve_work got nil" sleep 1 if [:blocking] return nil end |