Class: ThreeScale::Backend::WorkerSync
- Inherits:
-
Object
- Object
- ThreeScale::Backend::WorkerSync
- Includes:
- Worker
- Defined in:
- lib/3scale/backend/worker_sync.rb
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ WorkerSync
constructor
A new instance of WorkerSync.
- #work ⇒ Object
Methods included from Worker
new, #one_off?, #shutdown, #to_s, work
Methods included from Configurable
#configuration, #configuration=, included
Constructor Details
#initialize(options = {}) ⇒ WorkerSync
Returns a new instance of WorkerSync.
8 9 10 11 12 13 14 |
# File 'lib/3scale/backend/worker_sync.rb', line 8 def initialize( = {}) trap('TERM') { shutdown } trap('INT') { shutdown } @one_off = [:one_off] @job_fetcher = [:job_fetcher] || JobFetcher.new end |
Instance Method Details
#work ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/3scale/backend/worker_sync.rb', line 16 def work register_worker loop do break if @shutdown job = @job_fetcher.fetch perform(job) if job break if one_off? end unregister_worker end |