Class: Delayed::Worker::HealthCheck
- Inherits:
-
Object
- Object
- Delayed::Worker::HealthCheck
show all
- Defined in:
- lib/delayed/worker/health_check.rb
Class Attribute Summary collapse
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(worker_name:, config: {}) ⇒ HealthCheck
Returns a new instance of HealthCheck.
39
40
41
42
|
# File 'lib/delayed/worker/health_check.rb', line 39
def initialize(worker_name:, config: {})
@config = config.with_indifferent_access
@worker_name = worker_name
end
|
Class Attribute Details
.subclasses ⇒ Object
Returns the value of attribute subclasses.
8
9
10
|
# File 'lib/delayed/worker/health_check.rb', line 8
def subclasses
@subclasses
end
|
.type_name ⇒ Object
Returns the value of attribute type_name.
7
8
9
|
# File 'lib/delayed/worker/health_check.rb', line 7
def type_name
@type_name
end
|
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
37
38
39
|
# File 'lib/delayed/worker/health_check.rb', line 37
def config
@config
end
|
#worker_name ⇒ Object
Returns the value of attribute worker_name.
37
38
39
|
# File 'lib/delayed/worker/health_check.rb', line 37
def worker_name
@worker_name
end
|
Class Method Details
.build(type:, worker_name:, config: {}) ⇒ Object
14
15
16
17
18
19
|
# File 'lib/delayed/worker/health_check.rb', line 14
def build(type:, worker_name:, config: {})
type = type.to_sym
klass = @subclasses.find { |sc| sc.type_name == type }
raise ArgumentError, "Unable to build a HealthCheck for type #{type}" unless klass
klass.new(worker_name: worker_name, config: config)
end
|
.inherited(subclass) ⇒ Object
10
11
12
|
# File 'lib/delayed/worker/health_check.rb', line 10
def inherited(subclass)
@subclasses << subclass
end
|
.reschedule_abandoned_jobs ⇒ Object
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/delayed/worker/health_check.rb', line 21
def reschedule_abandoned_jobs
checker = Worker::HealthCheck.build(
type: Settings.worker_health_check_type,
config: Settings.worker_health_check_config,
worker_name: 'cleanup-crew'
)
live_workers = checker.live_workers
Delayed::Job.running_jobs.each do |job|
unless live_workers.include?(job.locked_by)
job.reschedule
end
end
end
|
Instance Method Details
#live_workers ⇒ Object
52
53
54
|
# File 'lib/delayed/worker/health_check.rb', line 52
def live_workers
raise NotImplementedError
end
|
#start ⇒ Object
44
45
46
|
# File 'lib/delayed/worker/health_check.rb', line 44
def start
raise NotImplementedError
end
|
#stop ⇒ Object
48
49
50
|
# File 'lib/delayed/worker/health_check.rb', line 48
def stop
raise NotImplementedError
end
|