Class: CassandraService

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from AbstractedCassandraRepository

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

Constructor Details

#initializeCassandraService

Returns a new instance of CassandraService.



9
10
11
12
# File 'lib/cassandra/cassandra_service.rb', line 9

def initialize
  puts 'init cassandra'
  self.cassandra_cluster = Cassandra.cluster
end

Instance Attribute Details

#cassandra_clusterObject

Returns the value of attribute cassandra_cluster.



7
8
9
# File 'lib/cassandra/cassandra_service.rb', line 7

def cassandra_cluster
  @cassandra_cluster
end

Instance Method Details

#start(keyspace_name) ⇒ Object



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

def start(keyspace_name)
  puts 'start cassandra, create cluster, session'
  if !cassandra_cluster
    cassandra_cluster = Cassandra.cluster
   end
   cassandra_cluster
end

#stopObject



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

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