Module: CassandraMigrations::Cassandra
- Extended by:
- KeyspaceOperations, Queries
- Defined in:
- lib/cassandra_migrations/cassandra.rb,
lib/cassandra_migrations/cassandra/queries.rb,
lib/cassandra_migrations/cassandra/query_result.rb,
lib/cassandra_migrations/cassandra/keyspace_operations.rb
Defined Under Namespace
Modules: KeyspaceOperations, Queries
Classes: QueryResult
Class Method Summary
collapse
Methods included from Queries
delete!, select, truncate!, update!, write!
create_keyspace!, create_keyspace_statement, drop_keyspace!
Class Method Details
.execute(*cql) ⇒ Object
67
68
69
70
71
72
|
# File 'lib/cassandra_migrations/cassandra.rb', line 67
def self.execute(*cql)
connect_to_server unless client
Rails.logger.try(:info, "\e[1;35m [Cassandra Migrations] \e[0m #{cql.to_s}")
result = client.execute(*cql)
QueryResult.new(result) if result
end
|
.restart ⇒ Object
34
35
36
37
38
39
40
41
|
# File 'lib/cassandra_migrations/cassandra.rb', line 34
def self.restart
if client
client.close if client.connected?
self.client = nil
end
start!
end
|
.restart! ⇒ Object
28
29
30
31
32
|
# File 'lib/cassandra_migrations/cassandra.rb', line 28
def self.restart!
raise Errors::ClientNotStartedError unless client
restart
end
|
.shutdown! ⇒ Object
43
44
45
46
47
48
|
# File 'lib/cassandra_migrations/cassandra.rb', line 43
def self.shutdown!
raise Errors::ClientNotStartedError unless client
client.close if client.connected?
self.client = nil
end
|
.start! ⇒ Object
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/cassandra_migrations/cassandra.rb', line 17
def self.start!
begin
use(Config.keyspace)
rescue Errors::MissingConfigurationError
Rails.logger.try(:warn, "There is no config/cassandra.yml. Skipping connection to Cassandra...")
end
end
|
.use(keyspace) ⇒ Object
56
57
58
59
60
61
62
63
64
65
|
# File 'lib/cassandra_migrations/cassandra.rb', line 56
def self.use(keyspace)
connect_to_server unless client
begin
client.use(keyspace)
rescue Exception => e puts "#{e} : #{e.message}"
raise Errors::UnexistingKeyspaceError, keyspace
end
end
|
.using_keyspace(keyspace, &block) ⇒ Object
50
51
52
53
54
|
# File 'lib/cassandra_migrations/cassandra.rb', line 50
def self.using_keyspace(keyspace, &block)
use(keyspace)
block.call
use(Config.keyspace)
end
|