fluent-plugin-mongo 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/AUTHORS +1 -0
 - data/README.rdoc +30 -0
 - data/Rakefile +32 -0
 - data/VERSION +1 -0
 - data/lib/fluent/plugin/out_mongo.rb +42 -0
 - metadata +97 -0
 
    
        data/AUTHORS
    ADDED
    
    | 
         @@ -0,0 +1 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            Masahiro Nakagawa <repeatedly _at_ gmail.com>
         
     | 
    
        data/README.rdoc
    ADDED
    
    | 
         @@ -0,0 +1,30 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            = MongoDB output plugin for Fluent
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            == Configuratin
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
                <match mongo.**>
         
     | 
| 
      
 6 
     | 
    
         
            +
                  type mongo
         
     | 
| 
      
 7 
     | 
    
         
            +
                  database fluent
         
     | 
| 
      
 8 
     | 
    
         
            +
                  collection test
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
                  # following attibutes are optional
         
     | 
| 
      
 11 
     | 
    
         
            +
                  host fluenter
         
     | 
| 
      
 12 
     | 
    
         
            +
                  port 10000
         
     | 
| 
      
 13 
     | 
    
         
            +
                </match>
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
            == TODO
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
            === TimeSlicedOutput version
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
            Currently, MemoryBufferChunk requires String object.
         
     | 
| 
      
 20 
     | 
    
         
            +
            But, Mongo client can push event-record to server directory.
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
            === Infer collection name
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
            Fluent tag is similar to database.collection in Mongo.
         
     | 
| 
      
 25 
     | 
    
         
            +
            This feature makes configuration more easily.
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
            == Copyright
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
            Copyright:: Copyright (c) 2011- Masahiro Nakagawa
         
     | 
| 
      
 30 
     | 
    
         
            +
            License::   Apache License, Version 2.0
         
     | 
    
        data/Rakefile
    ADDED
    
    | 
         @@ -0,0 +1,32 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'rake'
         
     | 
| 
      
 2 
     | 
    
         
            +
            require 'rake/testtask'
         
     | 
| 
      
 3 
     | 
    
         
            +
            require 'rake/clean'
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            begin
         
     | 
| 
      
 6 
     | 
    
         
            +
              require 'jeweler'
         
     | 
| 
      
 7 
     | 
    
         
            +
              Jeweler::Tasks.new do |gemspec|
         
     | 
| 
      
 8 
     | 
    
         
            +
                gemspec.name = "fluent-plugin-mongo"
         
     | 
| 
      
 9 
     | 
    
         
            +
                gemspec.summary = "MongoDB output plugin for Fluent event collector"
         
     | 
| 
      
 10 
     | 
    
         
            +
                gemspec.author = "Masahiro Nakagawa"
         
     | 
| 
      
 11 
     | 
    
         
            +
                gemspec.email = "repeatedly@gmail.com"
         
     | 
| 
      
 12 
     | 
    
         
            +
                gemspec.homepage = "http://github.com/fluent"
         
     | 
| 
      
 13 
     | 
    
         
            +
                gemspec.has_rdoc = false
         
     | 
| 
      
 14 
     | 
    
         
            +
                gemspec.require_paths = ["lib"]
         
     | 
| 
      
 15 
     | 
    
         
            +
                gemspec.add_dependency "fluent", "~> 0.9.14"
         
     | 
| 
      
 16 
     | 
    
         
            +
                gemspec.add_dependency "mongo", "~> 1.2.0"
         
     | 
| 
      
 17 
     | 
    
         
            +
                gemspec.test_files = Dir["test/**/*.rb"]
         
     | 
| 
      
 18 
     | 
    
         
            +
                gemspec.files = Dir["bin/**/*", "lib/**/*", "test/**/*.rb"] + %w[VERSION AUTHORS Rakefile]
         
     | 
| 
      
 19 
     | 
    
         
            +
                gemspec.executables = []
         
     | 
| 
      
 20 
     | 
    
         
            +
              end
         
     | 
| 
      
 21 
     | 
    
         
            +
              Jeweler::GemcutterTasks.new
         
     | 
| 
      
 22 
     | 
    
         
            +
            rescue LoadError
         
     | 
| 
      
 23 
     | 
    
         
            +
              puts "Jeweler not available. Install it with: gem install jeweler"
         
     | 
| 
      
 24 
     | 
    
         
            +
            end
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
            Rake::TestTask.new(:test) do |t|
         
     | 
| 
      
 27 
     | 
    
         
            +
              t.test_files = Dir['test/*_test.rb']
         
     | 
| 
      
 28 
     | 
    
         
            +
              t.ruby_opts = ['-rubygems'] if defined? Gem
         
     | 
| 
      
 29 
     | 
    
         
            +
              t.ruby_opts << '-I.'
         
     | 
| 
      
 30 
     | 
    
         
            +
            end
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
            task :default => [:build]
         
     | 
    
        data/VERSION
    ADDED
    
    | 
         @@ -0,0 +1 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            0.1.0
         
     | 
| 
         @@ -0,0 +1,42 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module Fluent
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            class MongoOutput < Output
         
     | 
| 
      
 5 
     | 
    
         
            +
              Fluent::Plugin.register_output('mongo', self)
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
              def initialize
         
     | 
| 
      
 8 
     | 
    
         
            +
                super
         
     | 
| 
      
 9 
     | 
    
         
            +
                require 'mongo'
         
     | 
| 
      
 10 
     | 
    
         
            +
              end
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
              def configure(conf)
         
     | 
| 
      
 13 
     | 
    
         
            +
                super
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
                raise ConfigError, "'database' parameter is required on file output"   unless @database = conf['database']
         
     | 
| 
      
 16 
     | 
    
         
            +
                raise ConfigError, "'collection' parameter is required on file output" unless @collection = conf['collection']
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
                @host = conf.has_key?('host') ? conf['host'] : 'localhost'
         
     | 
| 
      
 19 
     | 
    
         
            +
                @port = conf.has_key?('port') ? conf['port'] : 27017
         
     | 
| 
      
 20 
     | 
    
         
            +
              end
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
              def start
         
     | 
| 
      
 23 
     | 
    
         
            +
                super
         
     | 
| 
      
 24 
     | 
    
         
            +
                @collection = Mongo::Connection.new(@host, @port).db(@database).collection(@collection)
         
     | 
| 
      
 25 
     | 
    
         
            +
              end
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
              def shutdown
         
     | 
| 
      
 28 
     | 
    
         
            +
                # Mongo::Connection checks alive or closed myself
         
     | 
| 
      
 29 
     | 
    
         
            +
                @collection.db.connection.close
         
     | 
| 
      
 30 
     | 
    
         
            +
              end
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
              def emit(tag, event_stream, chain)
         
     | 
| 
      
 33 
     | 
    
         
            +
                event_stream.each { |event|
         
     | 
| 
      
 34 
     | 
    
         
            +
                  @collection.insert(event.record)
         
     | 
| 
      
 35 
     | 
    
         
            +
                }
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
                chain.next
         
     | 
| 
      
 38 
     | 
    
         
            +
              end
         
     | 
| 
      
 39 
     | 
    
         
            +
            end
         
     | 
| 
      
 40 
     | 
    
         
            +
             
     | 
| 
      
 41 
     | 
    
         
            +
             
     | 
| 
      
 42 
     | 
    
         
            +
            end
         
     | 
    
        metadata
    ADDED
    
    | 
         @@ -0,0 +1,97 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            --- !ruby/object:Gem::Specification 
         
     | 
| 
      
 2 
     | 
    
         
            +
            name: fluent-plugin-mongo
         
     | 
| 
      
 3 
     | 
    
         
            +
            version: !ruby/object:Gem::Version 
         
     | 
| 
      
 4 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 5 
     | 
    
         
            +
              segments: 
         
     | 
| 
      
 6 
     | 
    
         
            +
              - 0
         
     | 
| 
      
 7 
     | 
    
         
            +
              - 1
         
     | 
| 
      
 8 
     | 
    
         
            +
              - 0
         
     | 
| 
      
 9 
     | 
    
         
            +
              version: 0.1.0
         
     | 
| 
      
 10 
     | 
    
         
            +
            platform: ruby
         
     | 
| 
      
 11 
     | 
    
         
            +
            authors: 
         
     | 
| 
      
 12 
     | 
    
         
            +
            - Masahiro Nakagawa
         
     | 
| 
      
 13 
     | 
    
         
            +
            autorequire: 
         
     | 
| 
      
 14 
     | 
    
         
            +
            bindir: bin
         
     | 
| 
      
 15 
     | 
    
         
            +
            cert_chain: []
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
            date: 2011-09-28 00:00:00 +09:00
         
     | 
| 
      
 18 
     | 
    
         
            +
            default_executable: 
         
     | 
| 
      
 19 
     | 
    
         
            +
            dependencies: 
         
     | 
| 
      
 20 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency 
         
     | 
| 
      
 21 
     | 
    
         
            +
              name: fluent
         
     | 
| 
      
 22 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 23 
     | 
    
         
            +
              requirement: &id001 !ruby/object:Gem::Requirement 
         
     | 
| 
      
 24 
     | 
    
         
            +
                none: false
         
     | 
| 
      
 25 
     | 
    
         
            +
                requirements: 
         
     | 
| 
      
 26 
     | 
    
         
            +
                - - ~>
         
     | 
| 
      
 27 
     | 
    
         
            +
                  - !ruby/object:Gem::Version 
         
     | 
| 
      
 28 
     | 
    
         
            +
                    segments: 
         
     | 
| 
      
 29 
     | 
    
         
            +
                    - 0
         
     | 
| 
      
 30 
     | 
    
         
            +
                    - 9
         
     | 
| 
      
 31 
     | 
    
         
            +
                    - 14
         
     | 
| 
      
 32 
     | 
    
         
            +
                    version: 0.9.14
         
     | 
| 
      
 33 
     | 
    
         
            +
              type: :runtime
         
     | 
| 
      
 34 
     | 
    
         
            +
              version_requirements: *id001
         
     | 
| 
      
 35 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency 
         
     | 
| 
      
 36 
     | 
    
         
            +
              name: mongo
         
     | 
| 
      
 37 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 38 
     | 
    
         
            +
              requirement: &id002 !ruby/object:Gem::Requirement 
         
     | 
| 
      
 39 
     | 
    
         
            +
                none: false
         
     | 
| 
      
 40 
     | 
    
         
            +
                requirements: 
         
     | 
| 
      
 41 
     | 
    
         
            +
                - - ~>
         
     | 
| 
      
 42 
     | 
    
         
            +
                  - !ruby/object:Gem::Version 
         
     | 
| 
      
 43 
     | 
    
         
            +
                    segments: 
         
     | 
| 
      
 44 
     | 
    
         
            +
                    - 1
         
     | 
| 
      
 45 
     | 
    
         
            +
                    - 2
         
     | 
| 
      
 46 
     | 
    
         
            +
                    - 0
         
     | 
| 
      
 47 
     | 
    
         
            +
                    version: 1.2.0
         
     | 
| 
      
 48 
     | 
    
         
            +
              type: :runtime
         
     | 
| 
      
 49 
     | 
    
         
            +
              version_requirements: *id002
         
     | 
| 
      
 50 
     | 
    
         
            +
            description: 
         
     | 
| 
      
 51 
     | 
    
         
            +
            email: repeatedly@gmail.com
         
     | 
| 
      
 52 
     | 
    
         
            +
            executables: []
         
     | 
| 
      
 53 
     | 
    
         
            +
             
     | 
| 
      
 54 
     | 
    
         
            +
            extensions: []
         
     | 
| 
      
 55 
     | 
    
         
            +
             
     | 
| 
      
 56 
     | 
    
         
            +
            extra_rdoc_files: 
         
     | 
| 
      
 57 
     | 
    
         
            +
            - README.rdoc
         
     | 
| 
      
 58 
     | 
    
         
            +
            files: 
         
     | 
| 
      
 59 
     | 
    
         
            +
            - AUTHORS
         
     | 
| 
      
 60 
     | 
    
         
            +
            - Rakefile
         
     | 
| 
      
 61 
     | 
    
         
            +
            - VERSION
         
     | 
| 
      
 62 
     | 
    
         
            +
            - lib/fluent/plugin/out_mongo.rb
         
     | 
| 
      
 63 
     | 
    
         
            +
            - README.rdoc
         
     | 
| 
      
 64 
     | 
    
         
            +
            has_rdoc: true
         
     | 
| 
      
 65 
     | 
    
         
            +
            homepage: http://github.com/fluent
         
     | 
| 
      
 66 
     | 
    
         
            +
            licenses: []
         
     | 
| 
      
 67 
     | 
    
         
            +
             
     | 
| 
      
 68 
     | 
    
         
            +
            post_install_message: 
         
     | 
| 
      
 69 
     | 
    
         
            +
            rdoc_options: []
         
     | 
| 
      
 70 
     | 
    
         
            +
             
     | 
| 
      
 71 
     | 
    
         
            +
            require_paths: 
         
     | 
| 
      
 72 
     | 
    
         
            +
            - lib
         
     | 
| 
      
 73 
     | 
    
         
            +
            required_ruby_version: !ruby/object:Gem::Requirement 
         
     | 
| 
      
 74 
     | 
    
         
            +
              none: false
         
     | 
| 
      
 75 
     | 
    
         
            +
              requirements: 
         
     | 
| 
      
 76 
     | 
    
         
            +
              - - ">="
         
     | 
| 
      
 77 
     | 
    
         
            +
                - !ruby/object:Gem::Version 
         
     | 
| 
      
 78 
     | 
    
         
            +
                  segments: 
         
     | 
| 
      
 79 
     | 
    
         
            +
                  - 0
         
     | 
| 
      
 80 
     | 
    
         
            +
                  version: "0"
         
     | 
| 
      
 81 
     | 
    
         
            +
            required_rubygems_version: !ruby/object:Gem::Requirement 
         
     | 
| 
      
 82 
     | 
    
         
            +
              none: false
         
     | 
| 
      
 83 
     | 
    
         
            +
              requirements: 
         
     | 
| 
      
 84 
     | 
    
         
            +
              - - ">="
         
     | 
| 
      
 85 
     | 
    
         
            +
                - !ruby/object:Gem::Version 
         
     | 
| 
      
 86 
     | 
    
         
            +
                  segments: 
         
     | 
| 
      
 87 
     | 
    
         
            +
                  - 0
         
     | 
| 
      
 88 
     | 
    
         
            +
                  version: "0"
         
     | 
| 
      
 89 
     | 
    
         
            +
            requirements: []
         
     | 
| 
      
 90 
     | 
    
         
            +
             
     | 
| 
      
 91 
     | 
    
         
            +
            rubyforge_project: 
         
     | 
| 
      
 92 
     | 
    
         
            +
            rubygems_version: 1.3.7
         
     | 
| 
      
 93 
     | 
    
         
            +
            signing_key: 
         
     | 
| 
      
 94 
     | 
    
         
            +
            specification_version: 3
         
     | 
| 
      
 95 
     | 
    
         
            +
            summary: MongoDB output plugin for Fluent event collector
         
     | 
| 
      
 96 
     | 
    
         
            +
            test_files: []
         
     | 
| 
      
 97 
     | 
    
         
            +
             
     |