Class: SolidQueue::Semaphore

Inherits:
Record
  • Object
show all
Defined in:
app/models/solid_queue/semaphore.rb

Defined Under Namespace

Classes: Proxy

Class Method Summary collapse

Methods inherited from Record

non_blocking_lock

Class Method Details

.create_unique_by(attributes) ⇒ Object

Requires a unique index on key



22
23
24
25
26
27
28
29
30
# File 'app/models/solid_queue/semaphore.rb', line 22

def create_unique_by(attributes)
  if connection.supports_insert_conflict_target?
    insert({ **attributes }, unique_by: :key).any?
  else
    create!(**attributes)
  end
rescue ActiveRecord::RecordNotUnique
  false
end

.signal(job) ⇒ Object



13
14
15
# File 'app/models/solid_queue/semaphore.rb', line 13

def signal(job)
  Proxy.new(job).signal
end

.signal_all(jobs) ⇒ Object



17
18
19
# File 'app/models/solid_queue/semaphore.rb', line 17

def signal_all(jobs)
  Proxy.signal_all(jobs)
end

.wait(job) ⇒ Object



9
10
11
# File 'app/models/solid_queue/semaphore.rb', line 9

def wait(job)
  Proxy.new(job).wait
end