Class: Sidekiq::LimitFetch::Queues

Inherits:
Object
  • Object
show all
Defined in:
lib/sidekiq/limit_fetch/queues.rb

Constant Summary collapse

THREAD_KEY =
:acquired_queues

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Queues

Returns a new instance of Queues.



6
7
8
9
10
11
12
13
# File 'lib/sidekiq/limit_fetch/queues.rb', line 6

def initialize(options)
  @queues = options[:queues]
  options[:strict] ? strict_order! : weighted_order!

  set_selector options[:global]
  set_limits options[:limits]
  set_blocks options[:blocking]
end

Instance Attribute Details

#selectorObject (readonly)

Returns the value of attribute selector.



4
5
6
# File 'lib/sidekiq/limit_fetch/queues.rb', line 4

def selector
  @selector
end

Instance Method Details

#acquireObject



15
16
17
18
19
# File 'lib/sidekiq/limit_fetch/queues.rb', line 15

def acquire
  @selector.acquire(ordered_queues)
    .tap {|it| save it }
    .map {|it| "queue:#{it}" }
end

#ordered_queuesObject



46
# File 'lib/sidekiq/limit_fetch/queues.rb', line 46

def ordered_queues; @queues end

#release_except(full_name) ⇒ Object



21
22
23
# File 'lib/sidekiq/limit_fetch/queues.rb', line 21

def release_except(full_name)
  @selector.release restore.delete_if {|name| full_name.to_s.include? name }
end