Class: Sbmt::Outbox::V2::PollThrottler::FixedDelay

Inherits:
Base show all
Defined in:
lib/sbmt/outbox/v2/poll_throttler/fixed_delay.rb

Instance Method Summary collapse

Methods inherited from Base

#call

Methods inherited from DryInteractor

call

Constructor Details

#initialize(delay:) ⇒ FixedDelay

Returns a new instance of FixedDelay.



11
12
13
14
15
# File 'lib/sbmt/outbox/v2/poll_throttler/fixed_delay.rb', line 11

def initialize(delay:)
  super()

  @delay = delay
end

Instance Method Details

#wait(worker_num, poll_task, task_result) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/sbmt/outbox/v2/poll_throttler/fixed_delay.rb', line 17

def wait(worker_num, poll_task, task_result)
  return Success(Sbmt::Outbox::V2::Throttler::NOOP_STATUS) unless task_result == Sbmt::Outbox::V2::ThreadPool::PROCESSED

  sleep(@delay)

  Success(Sbmt::Outbox::V2::Throttler::THROTTLE_STATUS)
end