class TingYun::Agent::Dispatcher

Attributes

starting_pid[RW]

Public Class Methods

new(events, after_forker=TingYun::Agent) click to toggle source
# File lib/ting_yun/agent/dispatcher.rb, line 8
def initialize(events, after_forker=TingYun::Agent)
  # We intentionally don't set our pid as started at this point.
  # Startup routines must call mark_started when they consider us set!
  @starting_pid = nil
  @after_forker = after_forker

  if events
    events.subscribe(:start_transaction, &method(:on_transaction))
  end
end

Public Instance Methods

mark_started(pid = Process.pid) click to toggle source
# File lib/ting_yun/agent/dispatcher.rb, line 29
def mark_started(pid = Process.pid)
  @starting_pid = pid
end
needs_restart?(pid = Process.pid) click to toggle source
# File lib/ting_yun/agent/dispatcher.rb, line 33
def needs_restart?(pid = Process.pid)
  @starting_pid != pid
end
on_transaction(*_) click to toggle source
# File lib/ting_yun/agent/dispatcher.rb, line 19
def on_transaction(*_)
  return unless restart_in_children_enabled? && needs_restart?

  restart_harvest_thread
end
restart_harvest_thread() click to toggle source
# File lib/ting_yun/agent/dispatcher.rb, line 37
def restart_harvest_thread
  @after_forker.after_fork(:force_reconnect => true)
end
restart_in_children_enabled?() click to toggle source
# File lib/ting_yun/agent/dispatcher.rb, line 25
def restart_in_children_enabled?
  TingYun::Agent.config[:restart_thread_in_children]
end