Sha256: cf92dc1ed9915968a553b8f52f8b7b514c135af78b325d6dd5547497596c7961
Contents?: true
Size: 1.15 KB
Versions: 2
Compression:
Stored size: 1.15 KB
Contents
module Ej class Values attr_reader :client attr_reader :index attr_reader :logger def initialize(global_options) @logger = Logger.new($stderr) @logger.level = global_options[:debug] ? Logger::DEBUG : Logger::INFO @client = get_client(global_options[:host], global_options[:index], global_options[:user], global_options[:password]) @index = global_options[:index] end def get_client(host_string, index, user, password) host, port = (host_string || DEFAULT_HOST), DEFAULT_PORT if !host_string.nil? && host_string.include?(":") host, port = host_string.split(':') end hosts = [{ host: host, port: port, user: user, password: password }] transport = ::Elasticsearch::Transport::Transport::HTTP::Faraday.new( { hosts: hosts, options: { reload_connections: true, reload_on_failure: false, retry_on_failure: 5, transport_options: { request: { timeout: 300 } } } } ) ::Elasticsearch::Client.new transport: transport, index: index, logger: @logger end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ej-0.1.12 | lib/ej/values.rb |
ej-0.1.11 | lib/ej/values.rb |