Class: SolidQueue::Process

Inherits:
Record
  • Object
show all
Includes:
Prunable
Defined in:
app/models/solid_queue/process.rb

Defined Under Namespace

Modules: Prunable

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Record

non_blocking_lock

Class Method Details

.register(**attributes) ⇒ Object



14
15
16
17
18
19
20
21
# File 'app/models/solid_queue/process.rb', line 14

def self.register(**attributes)
  SolidQueue.instrument :register_process, **attributes do
    create!(attributes.merge(last_heartbeat_at: Time.current))
  end
rescue Exception => error
  SolidQueue.instrument :register_process, **attributes.merge(error: error)
  raise
end

Instance Method Details

#deregister(pruned: false) ⇒ Object



27
28
29
30
31
32
33
34
# File 'app/models/solid_queue/process.rb', line 27

def deregister(pruned: false)
  SolidQueue.instrument :deregister_process, process: self, pruned: pruned, claimed_size: claimed_executions.size do |payload|
    destroy!
  rescue Exception => error
    payload[:error] = error
    raise
  end
end

#heartbeatObject



23
24
25
# File 'app/models/solid_queue/process.rb', line 23

def heartbeat
  touch(:last_heartbeat_at)
end