class RocketJob::RactorWorker
Run each worker in its own “Ractor”.
Attributes
thread[R]
Public Class Methods
new(id:, server_name:)
click to toggle source
Calls superclass method
# File lib/rocket_job/ractor_worker.rb, line 6 def initialize(id:, server_name:) super(id: id, server_name: server_name) @shutdown = Concurrent::Event.new @thread = Ractor.new(name: "rocketjob-#{id}") { run } end
Public Instance Methods
alive?()
click to toggle source
# File lib/rocket_job/ractor_worker.rb, line 12 def alive? @thread.alive? end
backtrace()
click to toggle source
# File lib/rocket_job/ractor_worker.rb, line 16 def backtrace @thread.backtrace end
join(*args)
click to toggle source
# File lib/rocket_job/ractor_worker.rb, line 20 def join(*args) @thread.join(*args) end
kill()
click to toggle source
Send each active worker the RocketJob::ShutdownException so that stops processing immediately.
# File lib/rocket_job/ractor_worker.rb, line 25 def kill @thread.raise(Shutdown, "Shutdown due to kill request for worker: #{name}") if @thread.alive? end
shutdown!()
click to toggle source
# File lib/rocket_job/ractor_worker.rb, line 33 def shutdown! @shutdown.set end
shutdown?()
click to toggle source
# File lib/rocket_job/ractor_worker.rb, line 29 def shutdown? @shutdown.set? end
wait_for_shutdown?(timeout = nil)
click to toggle source
Returns [true|false] whether the shutdown indicator was set
# File lib/rocket_job/ractor_worker.rb, line 38 def wait_for_shutdown?(timeout = nil) @shutdown.wait(timeout) end