Class: Woodchuck::Agent
- Inherits:
-
Object
- Object
- Woodchuck::Agent
- Defined in:
- lib/woodchuck/agent.rb
Instance Attribute Summary collapse
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#output ⇒ Object
Returns the value of attribute output.
-
#paths ⇒ Object
Returns the value of attribute paths.
-
#watcher ⇒ Object
Returns the value of attribute watcher.
-
#watcher_thread ⇒ Object
Returns the value of attribute watcher_thread.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Agent
constructor
A new instance of Agent.
- #inspect ⇒ Object
- #start(blocking = false) ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Agent
Returns a new instance of Agent.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/woodchuck/agent.rb', line 11 def initialize(={}) @paths = [:paths] @logger = Woodchuck::Logger.new(::STDOUT) @mutex = Mutex.new @output = case [:output] when :stdout Woodchuck::Output::STDOUT.new when :zeromq Woodchuck::Output::ZeroMQ.new when :redis Woodchuck::Output::Redis.new else Woodchuck::Output::STDOUT.new end @watcher = Woodchuck::Watcher.new(self, @paths) end |
Instance Attribute Details
#logger ⇒ Object
Returns the value of attribute logger.
9 10 11 |
# File 'lib/woodchuck/agent.rb', line 9 def logger @logger end |
#output ⇒ Object
Returns the value of attribute output.
9 10 11 |
# File 'lib/woodchuck/agent.rb', line 9 def output @output end |
#paths ⇒ Object
Returns the value of attribute paths.
9 10 11 |
# File 'lib/woodchuck/agent.rb', line 9 def paths @paths end |
#watcher ⇒ Object
Returns the value of attribute watcher.
9 10 11 |
# File 'lib/woodchuck/agent.rb', line 9 def watcher @watcher end |
#watcher_thread ⇒ Object
Returns the value of attribute watcher_thread.
9 10 11 |
# File 'lib/woodchuck/agent.rb', line 9 def watcher_thread @watcher_thread end |
Instance Method Details
#inspect ⇒ Object
45 46 47 |
# File 'lib/woodchuck/agent.rb', line 45 def inspect to_s end |
#start(blocking = false) ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'lib/woodchuck/agent.rb', line 28 def start(blocking=false) @mutex.synchronize do return if @stop == false @stop = false end @watcher_thread = Thread.new { @watcher.start } @watcher_thread.join if blocking end |
#stop ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/woodchuck/agent.rb', line 37 def stop @mutex.synchronize do return if @stop == true @stop = true end Thread.kill(@watcher_thread) if @watcher_thread end |