Class: Sbmt::Outbox::V2::PollThrottler::RateLimited

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#call

Methods inherited from DryInteractor

call

Constructor Details

#initialize(limit: nil, interval: nil, balanced: true) ⇒ RateLimited

Returns a new instance of RateLimited.



13
14
15
16
17
18
19
# File 'lib/sbmt/outbox/v2/poll_throttler/rate_limited.rb', line 13

def initialize(limit: nil, interval: nil, balanced: true)
  @limit = limit
  @interval = interval
  @balanced = balanced
  @queues = {}
  @mutex = Mutex.new
end

Instance Attribute Details

#queuesObject (readonly)

Returns the value of attribute queues.



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

def queues
  @queues
end

Instance Method Details

#wait(_worker_num, poll_task, _task_result) ⇒ Object



21
22
23
24
25
# File 'lib/sbmt/outbox/v2/poll_throttler/rate_limited.rb', line 21

def wait(_worker_num, poll_task, _task_result)
  queue_for(poll_task).shift

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