quandl_cassandra 1.2.3 → 1.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +0 -1
- data/lib/quandl/cassandra/base/connection.rb +35 -23
- data/lib/quandl/cassandra/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b04729bd3d3e3675a93e9bbc6f0fef5cadd7c8c9
|
4
|
+
data.tar.gz: be46b8678c94354e2c6e6fa0afdd659ae18db3e9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 91c13e7f33ff01a8b0356c06fb40dbf3a960e896e2fca59108a75acc162c6283d763ca5622ac9b5417bf81584052660712e2f569be40693a9f2250a9bd3e25a2
|
7
|
+
data.tar.gz: b2c0492d2a9314c73911442843ea8d7dce3099823efc04167e04f5768e0e5b0c213f748847d68d595a21642d2319f7b41eb74b8b2a2d0499700e9a879b6a25a4
|
data/Gemfile
CHANGED
@@ -19,43 +19,55 @@ module Quandl::Cassandra::Base::Connection
|
|
19
19
|
with_connection do |c|
|
20
20
|
c.prepare(statement)
|
21
21
|
end
|
22
|
+
rescue Cql::QueryError
|
23
|
+
raise $!, "#{$!}\n statement: #{statement}", $!.backtrace
|
22
24
|
end
|
23
25
|
|
24
|
-
def execute_async(statement,
|
25
|
-
|
26
|
+
def execute_async(statement, consist = nil)
|
27
|
+
consist = consistency unless consist.present?
|
26
28
|
with_connection do |c|
|
27
|
-
c.async.execute( statement,
|
29
|
+
c.async.execute( statement, consist )
|
28
30
|
end
|
29
|
-
rescue Cql::QueryError
|
30
|
-
raise $!, "#{statement
|
31
|
+
rescue Cql::QueryError
|
32
|
+
raise $!, "#{$!}\n statement: #{statement}", $!.backtrace
|
31
33
|
end
|
32
34
|
|
33
|
-
def execute(statement,
|
34
|
-
|
35
|
+
def execute(statement, consist = nil)
|
36
|
+
consist = consistency unless consist.present?
|
35
37
|
with_connection do |c|
|
36
|
-
c.execute( statement,
|
38
|
+
c.execute( statement, consist )
|
37
39
|
end
|
38
|
-
rescue Cql::QueryError
|
39
|
-
raise $!, "#{statement
|
40
|
+
rescue Cql::QueryError
|
41
|
+
raise $!, "#{$!}\n statement: #{statement}", $!.backtrace
|
40
42
|
end
|
41
43
|
|
42
44
|
def with_connection(&block)
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
rescue Cql::Io::ConnectionError => err
|
47
|
-
Quandl::Logger.error(err)
|
48
|
-
reset_connection
|
49
|
-
raise
|
50
|
-
|
51
|
-
rescue Cql::NotConnectedError => err
|
52
|
-
Quandl::Logger.error(err)
|
53
|
-
reset_connection
|
54
|
-
raise
|
55
|
-
|
45
|
+
rescue_and_retry(2) do
|
46
|
+
block.call(connection)
|
56
47
|
end
|
57
48
|
end
|
58
49
|
|
50
|
+
def rescue_and_retry(times, &block)
|
51
|
+
|
52
|
+
block.call(connection)
|
53
|
+
|
54
|
+
rescue Cql::QueryError => err
|
55
|
+
#puts "ERROR: #{err.code} #{err}\n cql: '#{err.cql}'"
|
56
|
+
Quandl::Logger.error("#{err.code} '#{err.cql}' #{$!}")
|
57
|
+
# raise error if it's failed three times
|
58
|
+
raise( $!, "#{err.code} '#{err.cql}' #{$!}", $!.backtrace ) if times <= 1
|
59
|
+
# otherwise rescue and retry
|
60
|
+
rescue_and_retry(times - 1, &block)
|
61
|
+
|
62
|
+
rescue Cql::Io::ConnectionError, Cql::NotConnectedError => err
|
63
|
+
#puts "ERROR: #{err}"
|
64
|
+
Quandl::Logger.error(err)
|
65
|
+
reset_connection
|
66
|
+
raise if times <= 1
|
67
|
+
rescue_and_retry(times - 1, &block)
|
68
|
+
|
69
|
+
end
|
70
|
+
|
59
71
|
def connection
|
60
72
|
@@connection ||= establish_connection
|
61
73
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: quandl_cassandra
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Blake Hilscher
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-12-
|
11
|
+
date: 2013-12-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|