Module: Sidekiq::LimitFetch::Global::Selector

Extended by:
Selector
Included in:
Selector
Defined in:
lib/sidekiq/limit_fetch/global/selector.rb

Instance Method Summary collapse

Instance Method Details

#acquire(queues, namespace) ⇒ Object



5
6
7
# File 'lib/sidekiq/limit_fetch/global/selector.rb', line 5

def acquire(queues, namespace)
  redis_eval :acquire, [namespace, uuid, queues]
end

#release(queues, namespace) ⇒ Object



9
10
11
# File 'lib/sidekiq/limit_fetch/global/selector.rb', line 9

def release(queues, namespace)
  redis_eval :release, [namespace, uuid, queues]
end

#uuidObject



13
14
15
16
17
18
19
20
21
# File 'lib/sidekiq/limit_fetch/global/selector.rb', line 13

def uuid
  # - if we'll remove "@uuid ||=" from inside of mutex
  # then @uuid can be overwritten
  # - if we'll remove "@uuid ||=" from outside of mutex
  # then each read will lead to mutex
  @uuid ||= Thread.exclusive do
    @uuid || SecureRandom.uuid
  end
end