Class: Fluent::MongoTailInput
- Inherits:
-
Input
- Object
- Input
- Fluent::MongoTailInput
- Includes:
- MongoUtil
- Defined in:
- lib/fluent/plugin/in_mongo_tail.rb
Instance Method Summary collapse
- #configure(conf) ⇒ Object
-
#initialize ⇒ MongoTailInput
constructor
A new instance of MongoTailInput.
- #run ⇒ Object
- #shutdown ⇒ Object
- #start ⇒ Object
Methods included from MongoUtil
Constructor Details
#initialize ⇒ MongoTailInput
Returns a new instance of MongoTailInput.
24 25 26 27 28 |
# File 'lib/fluent/plugin/in_mongo_tail.rb', line 24 def initialize super require 'mongo' require 'bson' end |
Instance Method Details
#configure(conf) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/fluent/plugin/in_mongo_tail.rb', line 30 def configure(conf) super if !@tag and !@tag_key raise ConfigError, "'tag' or 'tag_key' option is required on mongo_tail input" end @last_id = @id_store_file ? get_last_id : nil $log.debug "Setup mongo_tail configuration: mode = #{@id_store_file ? 'persistent' : 'non-persistent'}" end |
#run ⇒ Object
60 61 62 63 64 |
# File 'lib/fluent/plugin/in_mongo_tail.rb', line 60 def run loop { tailoop(Mongo::Cursor.new(@client, cursor_conf)) } end |
#shutdown ⇒ Object
49 50 51 52 53 54 55 56 57 58 |
# File 'lib/fluent/plugin/in_mongo_tail.rb', line 49 def shutdown if @id_store_file save_last_id @file.close end @thread.join @client.db.connection.close super end |
#start ⇒ Object
42 43 44 45 46 47 |
# File 'lib/fluent/plugin/in_mongo_tail.rb', line 42 def start super @file = get_id_store_file if @id_store_file @client = get_capped_collection @thread = Thread.new(&method(:run)) end |