Class: Ej::Values
- Inherits:
-
Object
- Object
- Ej::Values
- Defined in:
- lib/ej/values.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#index ⇒ Object
readonly
Returns the value of attribute index.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
Instance Method Summary collapse
- #get_client(host_string, index) ⇒ Object
-
#initialize(global_options) ⇒ Values
constructor
A new instance of Values.
Constructor Details
#initialize(global_options) ⇒ Values
Returns a new instance of Values.
7 8 9 10 11 12 |
# File 'lib/ej/values.rb', line 7 def initialize() @logger = Logger.new($stderr) @logger.level = [:debug] ? Logger::DEBUG : Logger::INFO @client = get_client([:host], [:index]) @index = [:index] end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
3 4 5 |
# File 'lib/ej/values.rb', line 3 def client @client end |
#index ⇒ Object (readonly)
Returns the value of attribute index.
4 5 6 |
# File 'lib/ej/values.rb', line 4 def index @index end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
5 6 7 |
# File 'lib/ej/values.rb', line 5 def logger @logger end |
Instance Method Details
#get_client(host_string, index) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/ej/values.rb', line 14 def get_client(host_string, index) 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 }] 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 |