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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 756eb2a45036fe393963ff6941347c29decb2ac4
4
- data.tar.gz: 795fda4ec1224d696794799cc425e26332070214
3
+ metadata.gz: b04729bd3d3e3675a93e9bbc6f0fef5cadd7c8c9
4
+ data.tar.gz: be46b8678c94354e2c6e6fa0afdd659ae18db3e9
5
5
  SHA512:
6
- metadata.gz: a18fb65de10df02b1e298264c7094f8e382feb9081c0cb95602eddf7738d172ff0f43a9854db5604444596a6f1f276145fef82edab362a0ecc7eff4ad0c2e8e0
7
- data.tar.gz: 7c35c8eaae1fb3177dfb8014fa4f569783ab5814e487eb3217990d153fd3d1330f9b22083bf91c1877b43392ee996e8980a8d1038d3f9a8d0328a3c3e329fe10
6
+ metadata.gz: 91c13e7f33ff01a8b0356c06fb40dbf3a960e896e2fca59108a75acc162c6283d763ca5622ac9b5417bf81584052660712e2f569be40693a9f2250a9bd3e25a2
7
+ data.tar.gz: b2c0492d2a9314c73911442843ea8d7dce3099823efc04167e04f5768e0e5b0c213f748847d68d595a21642d2319f7b41eb74b8b2a2d0499700e9a879b6a25a4
data/Gemfile CHANGED
@@ -7,5 +7,4 @@ local_gem_dir = ENV['BUNDLE_LOCAL_DIR']
7
7
  if use_local_gems
8
8
  gem 'quandl_data', path: "#{local_gem_dir}/quandl/data"
9
9
  gem 'quandl_operation', path: "#{local_gem_dir}/quandl/operation"
10
- gem 'quandl_babelfish', path: "#{local_gem_dir}/quandl/babelfish"
11
10
  end
@@ -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, query_consistency = nil)
25
- query_consistency = consistency unless query_consistency.present?
26
+ def execute_async(statement, consist = nil)
27
+ consist = consistency unless consist.present?
26
28
  with_connection do |c|
27
- c.async.execute( statement, query_consistency )
29
+ c.async.execute( statement, consist )
28
30
  end
29
- rescue Cql::QueryError => e
30
- raise $!, "#{statement} #{$!}", $!.backtrace
31
+ rescue Cql::QueryError
32
+ raise $!, "#{$!}\n statement: #{statement}", $!.backtrace
31
33
  end
32
34
 
33
- def execute(statement, qconsistency = nil)
34
- qconsistency = consistency unless qconsistency.present?
35
+ def execute(statement, consist = nil)
36
+ consist = consistency unless consist.present?
35
37
  with_connection do |c|
36
- c.execute( statement, qconsistency )
38
+ c.execute( statement, consist )
37
39
  end
38
- rescue Cql::QueryError => e
39
- raise $!, "#{statement} #{$!}", $!.backtrace
40
+ rescue Cql::QueryError
41
+ raise $!, "#{$!}\n statement: #{statement}", $!.backtrace
40
42
  end
41
43
 
42
44
  def with_connection(&block)
43
- begin
44
- yield(connection)
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
@@ -1,5 +1,5 @@
1
1
  module Quandl
2
2
  module Cassandra
3
- VERSION = '1.2.3'
3
+ VERSION = '1.2.4'
4
4
  end
5
5
  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.3
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-08 00:00:00.000000000 Z
11
+ date: 2013-12-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake