Class: Sbmt::Outbox::V2::PollThrottler::RateLimited
- Inherits:
-
Base
- Object
- DryInteractor
- Base
- Sbmt::Outbox::V2::PollThrottler::RateLimited
- Defined in:
- lib/sbmt/outbox/v2/poll_throttler/rate_limited.rb
Instance Attribute Summary collapse
-
#queues ⇒ Object
readonly
Returns the value of attribute queues.
Instance Method Summary collapse
-
#initialize(limit: nil, interval: nil, balanced: true) ⇒ RateLimited
constructor
A new instance of RateLimited.
- #wait(_worker_num, poll_task, _task_result) ⇒ Object
Methods inherited from Base
Methods inherited from DryInteractor
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
#queues ⇒ Object (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 |