Class: Eurydice::Pelops::Cluster
- Inherits:
-
Object
- Object
- Eurydice::Pelops::Cluster
- Defined in:
- lib/eurydice/pelops/cluster.rb
Instance Method Summary collapse
- #connected? ⇒ Boolean
-
#initialize(cluster, driver = ::Pelops::Pelops) ⇒ Cluster
constructor
A new instance of Cluster.
- #keyspace(keyspace_name, options = {}) ⇒ Object
- #keyspaces ⇒ Object
- #nodes ⇒ Object
Constructor Details
#initialize(cluster, driver = ::Pelops::Pelops) ⇒ Cluster
Returns a new instance of Cluster.
6 7 8 9 |
# File 'lib/eurydice/pelops/cluster.rb', line 6 def initialize(cluster, driver=::Pelops::Pelops) @cluster = cluster @driver = driver end |
Instance Method Details
#connected? ⇒ Boolean
11 12 13 14 15 16 |
# File 'lib/eurydice/pelops/cluster.rb', line 11 def connected? @driver.create_cluster_manager(@cluster).cassandra_version true rescue Exception => e false end |
#keyspace(keyspace_name, options = {}) ⇒ Object
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/eurydice/pelops/cluster.rb', line 18 def keyspace(keyspace_name, ={}) pool_name = .fetch(:pool_name, "eurydice_#{keyspace_name}_pool") create = .fetch(:create, true) unless @driver.get_db_conn_pool(pool_name) @driver.add_pool(pool_name, @cluster, keyspace_name) end keyspace = Keyspace.new(keyspace_name, @cluster, pool_name, @driver) keyspace.create! if create && !keyspace.exists? keyspace end |
#keyspaces ⇒ Object
29 30 31 |
# File 'lib/eurydice/pelops/cluster.rb', line 29 def keyspaces keyspace_manager.keyspace_names.map { |ks_def| ks_def.name } end |
#nodes ⇒ Object
33 34 35 |
# File 'lib/eurydice/pelops/cluster.rb', line 33 def nodes @cluster.nodes.map { |n| n.address } end |