Class: Capturing::ForwardRunner

Inherits:
Runner
  • Object
show all
Defined in:
lib/capture.rb

Instance Method Summary collapse

Methods inherited from Runner

#destroy!, #run!

Constructor Details

#initialize(e, host:, port:, fluentd_config: nil) ⇒ ForwardRunner

Returns a new instance of ForwardRunner.



79
80
81
82
83
84
85
86
87
88
# File 'lib/capture.rb', line 79

def initialize(e, host:, port:, fluentd_config: nil)
  super e
  @host = host
  @port = port
  @fluentd_config = fluentd_config

  start_embed_fluentd(fluentd_config) unless fluentd_config.nil?
  @sock = new_socket_to_forward
  @messaging_thread_pool = ThreadPool.new(4) # TODO configurable
end

Instance Method Details

#on_packet(data) ⇒ Object



90
91
92
93
# File 'lib/capture.rb', line 90

def on_packet(data)
  @messaging_thread_pool.process{ @sock.write data }
  @exec.logger.info "Forwarded message to #{@host}:#{@port}" unless @use_embed_fluentd
end