Class: AtomicSidekiq::AtomicFetch
- Inherits:
-
Object
- Object
- AtomicSidekiq::AtomicFetch
- Defined in:
- lib/atomic_sidekiq/atomic_fetch.rb
Constant Summary collapse
- IN_FLIGHT_KEY_PREFIX =
"flight".freeze
- DEFAULT_POLL_INTERVAL =
seconds
5
- DEFAULT_EXPIRATION_TIME =
seconds
3600
- DEFAULT_COLLECTION_INTERVAL =
seconds
60
Instance Method Summary collapse
-
#initialize(options, in_flight_keymaker: nil) ⇒ AtomicFetch
constructor
A new instance of AtomicFetch.
- #retrieve_work ⇒ Object
Constructor Details
#initialize(options, in_flight_keymaker: nil) ⇒ AtomicFetch
Returns a new instance of AtomicFetch.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/atomic_sidekiq/atomic_fetch.rb', line 9 def initialize(, in_flight_keymaker: nil) @keymaker = in_flight_keymaker || InFlightKeymaker.new(IN_FLIGHT_KEY_PREFIX) @retrieve_op = AtomicOperation::Retrieve.new( in_flight_keymaker: keymaker ) @queues ||= [:queues].map { |q| "queue:#{q}" } @strictly_ordered_queues = !![:strict] @@next_collection ||= Time.now configure_atomic_fetch(.fetch(:atomic_fetch, {})) end |
Instance Method Details
#retrieve_work ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/atomic_sidekiq/atomic_fetch.rb', line 24 def retrieve_work collect_dead_jobs! work = retrieve_op.perform(ordered_queues, expire_at) return UnitOfWork.new(*work, in_flight_keymaker: keymaker) if work sleep(poll_interval) nil end |