Class: ElasticGraph::DatastoreCore::Configuration::ClusterDefinition

Inherits:
Object
  • Object
show all
Defined in:
lib/elastic_graph/datastore_core/configuration/cluster_definition.rb

Constant Summary collapse

BACKEND_CLIENT_CLASSES =
{
  "elasticsearch" => "ElasticGraph::Elasticsearch::Client",
  "opensearch" => "ElasticGraph::OpenSearch::Client"
}

Class Method Summary collapse

Class Method Details

.definitions_by_name_hash_from(cluster_def_hash_by_name) ⇒ Object



32
33
34
35
36
# File 'lib/elastic_graph/datastore_core/configuration/cluster_definition.rb', line 32

def self.definitions_by_name_hash_from(cluster_def_hash_by_name)
  cluster_def_hash_by_name.transform_values do |cluster_def_hash|
    from_hash(cluster_def_hash)
  end
end

.from_hash(hash) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
# File 'lib/elastic_graph/datastore_core/configuration/cluster_definition.rb', line 20

def self.from_hash(hash)
  backend_name = hash.fetch("backend")
  require "elastic_graph/#{backend_name}/client"
  backend_client_class = ::Object.const_get(BACKEND_CLIENT_CLASSES.fetch(backend_name))

  new(
    url: hash.fetch("url"),
    backend_client_class: backend_client_class,
    settings: hash.fetch("settings")
  )
end