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!, drop_keyspace!
Class Method Details
.execute(cql) ⇒ Object
52
53
54
55
56
57
|
# File 'lib/cassandra_migrations/cassandra.rb', line 52
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
27
28
29
30
31
32
33
|
# File 'lib/cassandra_migrations/cassandra.rb', line 27
def self.restart!
raise Errors::ClientNotStartedError unless client
client.close if client && client.connected?
self.client = nil
start!
end
|
.shutdown! ⇒ Object
35
36
37
38
39
40
|
# File 'lib/cassandra_migrations/cassandra.rb', line 35
def self.shutdown!
raise Errors::ClientNotStartedError unless client
client.close if client.connected?
self.client = nil
end
|
.start! ⇒ Object
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/cassandra_migrations/cassandra.rb', line 16
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
42
43
44
45
46
47
48
49
50
|
# File 'lib/cassandra_migrations/cassandra.rb', line 42
def self.use(keyspace)
connect_to_server unless client
begin
client.use(keyspace)
rescue Cql::QueryError raise Errors::UnexistingKeyspaceError, keyspace
end
end
|