Module: ThreeScale::Backend::Worker
Overview
This is a module that’s meant to be included from the different workers. Now we have WorkerSync and WorkerAsync. Those classes need to implement #work, which is responsible for fetching jobs from the queue and running them by calling perform(job).
Class Method Summary
collapse
Instance Method Summary
collapse
#configuration, #configuration=, included
Class Method Details
.new(options = {}) ⇒ Object
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/3scale/backend/worker.rb', line 20
def self.new(options = {})
Logging::Worker.configure_logging(self, options[:log_file])
Logging::External.setup_worker
if configuration.worker_prometheus_metrics.enabled
require '3scale/backend/worker_metrics'
WorkerMetrics.start_metrics_server
end
if options[:async]
require '3scale/backend/worker_async'
WorkerAsync.new(options)
else
require '3scale/backend/worker_sync'
WorkerSync.new(options)
end
end
|
.work(options = {}) ⇒ Object
44
45
46
47
48
|
# File 'lib/3scale/backend/worker.rb', line 44
def self.work(options = {})
Process.setproctitle("3scale_backend_worker #{Backend::VERSION}")
options[:async] = configuration.redis.async
new(options).work
end
|
Instance Method Details
#one_off? ⇒ Boolean
62
63
64
|
# File 'lib/3scale/backend/worker.rb', line 62
def one_off?
@one_off
end
|
#shutdown ⇒ Object
54
55
56
|
# File 'lib/3scale/backend/worker.rb', line 54
def shutdown
@shutdown = true
end
|
#to_s ⇒ Object
58
59
60
|
# File 'lib/3scale/backend/worker.rb', line 58
def to_s
@to_s ||= "#{hostname}:#{Process.pid}"
end
|
#work ⇒ Object
50
51
52
|
# File 'lib/3scale/backend/worker.rb', line 50
def work
raise 'Missing implementation of #work'
end
|