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.
23 24 25 26 27 |
# File 'lib/fluent/plugin/in_mongo_tail.rb', line 23 def initialize super require 'mongo' require 'bson' end |
Instance Method Details
#configure(conf) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/fluent/plugin/in_mongo_tail.rb', line 29 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
59 60 61 62 63 |
# File 'lib/fluent/plugin/in_mongo_tail.rb', line 59 def run loop { tailoop(Mongo::Cursor.new(@client, cursor_conf)) } end |
#shutdown ⇒ Object
48 49 50 51 52 53 54 55 56 57 |
# File 'lib/fluent/plugin/in_mongo_tail.rb', line 48 def shutdown if @id_store_file save_last_id @file.close end @thread.join @client.db.connection.close super end |
#start ⇒ Object
41 42 43 44 45 46 |
# File 'lib/fluent/plugin/in_mongo_tail.rb', line 41 def start super @file = get_id_store_file if @id_store_file @client = get_capped_collection @thread = Thread.new(&method(:run)) end |