Class: ElasticSearch::Node::Embedded

Inherits:
Object
  • Object
show all
Includes:
ClientProvider
Defined in:
lib/elasticsearch-node/embedded.rb

Instance Method Summary collapse

Methods included from ClientProvider

included

Constructor Details

#initialize(opts = {}) ⇒ Embedded

Returns a new instance of Embedded.



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/elasticsearch-node/embedded.rb', line 13

def initialize(opts = {})
  node_builder = org.elasticsearch.node.NodeBuilder.nodeBuilder.loadConfigSettings(true)
  settings_builder = org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder
  
  if opts[:config]
    settings_builder.put("path.home", opts[:config])
  end
  
  settings_builder.put(opts[:settings]) if opts[:settings]
  
  tuple = org.elasticsearch.node.internal.InternalSettingsPerparer.prepareSettings(settings_builder.build, true)
  org.elasticsearch.common.logging.log4j.LogConfigurator.configure(tuple.v1());
  @node = node_builder.settings(settings_builder).node
  super(opts)
end

Instance Method Details

#clientObject



37
38
39
# File 'lib/elasticsearch-node/embedded.rb', line 37

def client
  @node.client
end

#closeObject



41
42
43
# File 'lib/elasticsearch-node/embedded.rb', line 41

def close
  @node.close
end

#ipObject



33
34
35
# File 'lib/elasticsearch-node/embedded.rb', line 33

def ip
  socket_address.host_string
end

#portObject



29
30
31
# File 'lib/elasticsearch-node/embedded.rb', line 29

def port
  Integer(socket_address.port)
end