class Async::Container::Supervisor::Worker
There are various tasks that can be executed by the worker, such as dumping memory, threads, and garbage collection profiles.
A worker represents a long running process that can be controlled by the supervisor.
def self.run(...)
def self.run(...) self.new(...).run end
def connected!(connection)
def connected!(connection) r the worker with the supervisor: n.call(do: :register, state: @state)
def do_garbage_profile_start(call)
def do_garbage_profile_start(call) GC::Profiler.enable call.finish(started: true) end
def do_garbage_profile_stop(call)
def do_garbage_profile_stop(call) GC::Profiler.disable dump(connection, message) do |file| file.puts GC::Profiler.result end end
def do_memory_dump(call)
def do_memory_dump(call) require "objspace" dump(call) do |file| ObjectSpace.dump_all(output: file) end end
def do_scheduler_dump(call)
def do_scheduler_dump(call) dump(call) do |file| Fiber.scheduler.print_hierarchy(file) end end
def do_thread_dump(call)
def do_thread_dump(call) dump(call) do |file| Thread.list.each do |thread| file.puts(thread.inspect) file.puts(thread.backtrace) end end end
def dump(call)
def dump(call) = call[:path] pen(path, "w") do |file| file inish(path: path) = StringIO.new buffer inish(data: buffer.string)
def initialize(state, endpoint: Supervisor.endpoint)
def initialize(state, endpoint: Supervisor.endpoint) @state = state @endpoint = endpoint end