Class: ElasticGraph::DatastoreCore::Configuration::ClusterDefinition
- Inherits:
-
Object
- Object
- ElasticGraph::DatastoreCore::Configuration::ClusterDefinition
- Defined in:
- lib/elastic_graph/datastore_core/configuration/cluster_definition.rb
Constant Summary collapse
- EXPECTED_KEYS =
members.map(&:to_s) - ["backend_client_class"] + ["backend"]
Class Method Summary collapse
Class Method Details
.definitions_by_name_hash_from(cluster_def_hash_by_name) ⇒ Object
42 43 44 45 46 |
# File 'lib/elastic_graph/datastore_core/configuration/cluster_definition.rb', line 42 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
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/elastic_graph/datastore_core/configuration/cluster_definition.rb', line 15 def self.from_hash(hash) extra_keys = hash.keys - EXPECTED_KEYS unless extra_keys.empty? raise ConfigError, "Unknown `datastore.clusters` config settings: #{extra_keys.join(", ")}" end backend_name = hash["backend"] backend_client_class = case backend_name when "elasticsearch" require "elastic_graph/elasticsearch/client" Elasticsearch::Client when "opensearch" require "elastic_graph/opensearch/client" OpenSearch::Client else raise ConfigError, "Unknown `datastore.clusters` backend: `#{backend_name}`. Valid backends are `elasticsearch` and `opensearch`." end new( url: hash.fetch("url"), backend_client_class: backend_client_class, settings: hash.fetch("settings") ) end |