Class: Droonga::WorkerProcessAgent

Inherits:
Object
  • Object
show all
Includes:
Loggable, ProcessControlProtocol
Defined in:
lib/droonga/worker_process_agent.rb

Instance Method Summary collapse

Constructor Details

#initialize(loop, input, output) ⇒ WorkerProcessAgent

Returns a new instance of WorkerProcessAgent.



27
28
29
30
31
# File 'lib/droonga/worker_process_agent.rb', line 27

def initialize(loop, input, output)
  @loop = loop
  create_input(input)
  create_output(output)
end

Instance Method Details

#on_refresh_node_reference=(callback) ⇒ Object



80
81
82
# File 'lib/droonga/worker_process_agent.rb', line 80

def on_refresh_node_reference=(callback)
  @on_refresh_node_reference = callback
end

#on_refresh_self_reference=(callback) ⇒ Object



76
77
78
# File 'lib/droonga/worker_process_agent.rb', line 76

def on_refresh_self_reference=(callback)
  @on_refresh_self_reference = callback
end

#on_stop_gracefully=(callback) ⇒ Object



68
69
70
# File 'lib/droonga/worker_process_agent.rb', line 68

def on_stop_gracefully=(callback)
  @on_stop_gracefully = callback
end

#on_stop_immediately=(callback) ⇒ Object



72
73
74
# File 'lib/droonga/worker_process_agent.rb', line 72

def on_stop_immediately=(callback)
  @on_stop_immediately = callback
end

#readyObject



64
65
66
# File 'lib/droonga/worker_process_agent.rb', line 64

def ready
  @output.write(Messages::READY)
end

#startObject



33
34
35
36
37
38
39
40
41
42
# File 'lib/droonga/worker_process_agent.rb', line 33

def start
  logger.trace("start: start")
  @loop.attach(@input)
  # logger.trace("start: new input watcher attached",
  #              :watcher => @input)
  @loop.attach(@output)
  # logger.trace("start: new output watcher attached",
  #              :watcher => @output)
  logger.trace("start: done")
end

#stopObject



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/droonga/worker_process_agent.rb', line 44

def stop
  logger.trace("stop: start")
  if @output
    @output, output = nil, @output
    output.write(Messages::FINISH)
    output.on_write_complete do
      output.close
      logger.trace("stop: output detached",
                   :watcher => output)
    end
  end
  if @input
    @input, input = nil, @input
    input.close
    logger.trace("stop: input detached",
                 :watcher => input)
  end
  logger.trace("stop: done")
end