Sha256: 206dafb6b87dd1aeba84f5e7e5ec5f8322c362b59b3201df8db003565bfb7847

Contents?: true

Size: 551 Bytes

Versions: 3

Compression:

Stored size: 551 Bytes

Contents

require 'securerandom'
require 'base64'

module Fluent
  module Plugin
    module GenerateHashIdSupport
      def self.included(klass)
        klass.instance_eval {
          config_section :hash, param_name: :hash_config, required: false, multi: false do
            config_param :hash_id_key, :string, default: '_id'
          end
        }
      end

      def generate_hash_id_key(record)
        s = ""
        s += Base64.strict_encode64(SecureRandom.uuid)
        record[@hash_config.hash_id_key] = s
        record
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
fluent-plugin-elasticsearch-2.1.0 lib/fluent/plugin/generate_hash_id_support.rb
fluent-plugin-elasticsearch-2.0.1 lib/fluent/plugin/generate_hash_id_support.rb
fluent-plugin-elasticsearch-2.0.1.rc.1 lib/fluent/plugin/generate_hash_id_support.rb