Sha256: 09dc7b479c251696789b125eddde0725cdd3550989a9429c1853aa6464d68d41

Contents?: true

Size: 1.49 KB

Versions: 13

Compression:

Stored size: 1.49 KB

Contents

class Fluentd
  module Setting
    class OutMongo
      include Common

      KEYS = [
        :match,
        :host, :port, :database, :collection, :capped, :capped_size, :capped_max, :user, :password, :tag_mapped,
        :buffer_type, :buffer_queue_limit, :buffer_chunk_limit, :flush_interval,  :retry_wait, :retry_limit, :max_retry_wait, :num_threads,
      ].freeze

      attr_accessor(*KEYS)

      flags :capped, :tag_mapped

      validates :match, presence: true
      validates :host, presence: true
      validates :port, presence: true
      validates :database, presence: true
      validate :validate_capped
      validate :validate_collection

      def validate_capped
        return true if capped.blank?
        errors.add(:capped_size, :blank) if capped_size.blank?
      end

      def validate_collection
        if tag_mapped.blank? && collection.blank?
          errors.add(:collection, :blank) 
        end
      end

      def self.initial_params
        {
          host: "127.0.0.1",
          port: 27017,
          capped: true,
          capped_size: "100m",
        }
      end

      def common_options
        [
          :match, :host, :port, :database, :collection,
          :tag_mapped, :user, :password,
        ]
      end

      def advanced_options
        [
          :capped, :capped_size, :capped_max, :buffer_type, :buffer_queue_limit, :buffer_chunk_limit,
          :flush_interval, :retry_wait, :retry_limit, :max_retry_wait, :num_threads,
        ]
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
fluentd-ui-0.3.14 app/models/fluentd/setting/out_mongo.rb
fluentd-ui-0.3.13 app/models/fluentd/setting/out_mongo.rb
fluentd-ui-0.3.12 app/models/fluentd/setting/out_mongo.rb
fluentd-ui-0.3.11 app/models/fluentd/setting/out_mongo.rb
fluentd-ui-0.3.10 app/models/fluentd/setting/out_mongo.rb
fluentd-ui-0.3.9 app/models/fluentd/setting/out_mongo.rb
fluentd-ui-0.3.8 app/models/fluentd/setting/out_mongo.rb
fluentd-ui-0.3.7 app/models/fluentd/setting/out_mongo.rb
fluentd-ui-0.3.6 app/models/fluentd/setting/out_mongo.rb
fluentd-ui-0.3.5 app/models/fluentd/setting/out_mongo.rb
fluentd-ui-0.3.3 app/models/fluentd/setting/out_mongo.rb
fluentd-ui-0.3.2 app/models/fluentd/setting/out_mongo.rb
fluentd-ui-0.3.1 app/models/fluentd/setting/out_mongo.rb