Class: Carnivore::Source::CarnFile
- Inherits:
-
Carnivore::Source
- Object
- Carnivore::Source
- Carnivore::Source::CarnFile
- Defined in:
- lib/carnivore-files/carn_file.rb
Overview
Carnivore source for consumption from files
Instance Attribute Summary collapse
-
#fetcher ⇒ Symbol
readonly
Registry name of fetcher.
-
#message_queue ⇒ Queue
readonly
Queue to hold messages.
-
#path ⇒ String
readonly
Path to file.
Instance Method Summary collapse
-
#connect ⇒ Object
Start the line fetcher.
-
#receive(*_) ⇒ Array<Hash>
Return messages.
-
#setup(*_) ⇒ Object
Setup source.
-
#transmit(payload, *args) ⇒ Object
Send payload.
Instance Attribute Details
#fetcher ⇒ Symbol (readonly)
Returns registry name of fetcher.
11 12 13 |
# File 'lib/carnivore-files/carn_file.rb', line 11 def fetcher @fetcher end |
#message_queue ⇒ Queue (readonly)
Returns queue to hold messages.
13 14 15 |
# File 'lib/carnivore-files/carn_file.rb', line 13 def end |
#path ⇒ String (readonly)
Returns path to file.
9 10 11 |
# File 'lib/carnivore-files/carn_file.rb', line 9 def path @path end |
Instance Method Details
#connect ⇒ Object
Start the line fetcher
29 30 31 32 33 34 35 36 37 |
# File 'lib/carnivore-files/carn_file.rb', line 29 def connect case args[:foundation].to_sym when :poll @fetcher = Carnivore::Files::Util::Fetcher::Poll.new(args.merge(:queue => )) else @fetcher = Carnivore::Files::Util::Fetcher::Penguin.new(args.merge(:queue => )) end fetcher.async.start_fetcher end |
#receive(*_) ⇒ Array<Hash>
Return messages
40 41 42 |
# File 'lib/carnivore-files/carn_file.rb', line 40 def receive(*_) defer{ .pop } end |
#setup(*_) ⇒ Object
Setup source
20 21 22 23 24 25 26 |
# File 'lib/carnivore-files/carn_file.rb', line 20 def setup(*_) @path = ::File.(args[:path]) = Queue.new unless(args[:foundation]) args[:foundation] = RUBY_PLATFORM == 'java' ? :poll : :penguin end end |
#transmit(payload, *args) ⇒ Object
Send payload
47 48 49 |
# File 'lib/carnivore-files/carn_file.rb', line 47 def transmit(payload, *args) fetcher.write_line(payload) end |