Class: CassandraService

Inherits:
Object
  • Object
show all
Extended by:
CassandraConfiguration
Includes:
AbstractedCassandraRepository
Defined in:
lib/cassandra/cassandra_service.rb

Constant Summary

Constants included from CassandraConfiguration

CassandraConfiguration::CONFIG

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ApplicationConfiguration

#config, #config_cassandra, #config_consul, #config_rest, #random_name

Methods included from AbstractedCassandraRepository

#create, #delete, #find_all, #find_by_id, #run_query, #save, #update

Constructor Details

#initializeCassandraService

Returns a new instance of CassandraService.



15
16
17
18
# File 'lib/cassandra/cassandra_service.rb', line 15

def initialize
	# puts 'init cassandra'
   self.cassandra_cluster = Cassandra.cluster(CassandraConfiguration::CONFIG)
end

Instance Attribute Details

#cassandra_clusterObject

Returns the value of attribute cassandra_cluster.



13
14
15
# File 'lib/cassandra/cassandra_service.rb', line 13

def cassandra_cluster
  @cassandra_cluster
end

Instance Method Details

#startObject



20
21
22
23
24
25
26
# File 'lib/cassandra/cassandra_service.rb', line 20

def start
	# puts 'start cassandra, create cluster'
	if !cassandra_cluster
		cassandra_cluster = Cassandra.cluster(CassandraConfiguration::CONFIG)
   end
   cassandra_cluster
end

#stopObject



28
29
30
31
32
33
34
# File 'lib/cassandra/cassandra_service.rb', line 28

def stop
	# puts 'stop cassandra'
	if cassandra_cluster
		# puts 'closing'
   	cassandra_cluster.close
   end
end