Class: Doctrine::Worker

Inherits:
Object
  • Object
show all
Defined in:
lib/doctrine/worker.rb

Overview

public

Instance Method Summary collapse

Constructor Details

#initialize(queue:, runner:) ⇒ Worker

Returns a new instance of Worker.


7
8
9
10
# File 'lib/doctrine/worker.rb', line 7

def initialize(queue:, runner:)
  @queue = queue
  @runner = runner
end

Instance Method Details

#runObject

public

14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/doctrine/worker.rb', line 14

def run
  until @queue.closed?
    if (run = @queue.pop)
      begin
        @runner.starting(run)

        run.perform
      rescue => error
        run.errored(error)
      ensure
        @runner.finished(run)
      end
    end
  end
end