cequel 1.4.4 → 1.4.5

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: a43ac7eabfd0c08bc6351877501405dc45a0f0ee
4
- data.tar.gz: 9e926cb705192f68bfe3fb47cdb406de9c6829ac
3
+ metadata.gz: 4fba208e19ab7eabd8a3f2db192e68a4cc70bd48
4
+ data.tar.gz: 701fad60ff7b547719c39817abffd3b080a469a5
5
5
  SHA512:
6
- metadata.gz: ef9d853eab6fa701d06560fb903d410b7539434b0823fca9077db8e74c13301c86dded17fafd148c43c0825e74c89ff0578a833c17f5ab7ff29a9ee7b40b2f3e
7
- data.tar.gz: 1d979817ae7d022a2ea0fa96a7f64c232cf602a62f4561a66edd5aa17829b664f758bc5414da66abc0586a3228c440c9a58348bf1bc14501ac1b73a3a185f67a
6
+ metadata.gz: e94e957983915b7cb434dfdfb4cf913e47d25c687c17f2106d53730bd0624acacf74454c2ca64b29bfae5d31a8ff8bece1e1ef6dd7e19252c41e8de5dee305de
7
+ data.tar.gz: d9b7ae7438d6b188e5709357bf6c7ba21de7b0af3f26de5311290824381b4c66be2355318ac8cfe974e196f44e3b7b5ea866593adaa27d2797138db1039fa39b
@@ -1,3 +1,7 @@
1
+ ## 1.4.5
2
+
3
+ * Fix recovery from connection error
4
+
1
5
  ## 1.4.4
2
6
 
3
7
  * Round time to nearest millisecond when serializing for CQL
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cequel (1.4.4)
4
+ cequel (1.4.5)
5
5
  activemodel (>= 3.1, < 5.0)
6
6
  cql-rb (>= 1.2, < 3.0)
7
7
 
data/README.md CHANGED
@@ -569,6 +569,7 @@ Cequel was written by:
569
569
  * Tomohiro Nishimura
570
570
  * Masaki Takahashi
571
571
  * G Gordon Worley III
572
+ * Clark Bremer
572
573
 
573
574
  Special thanks to [Brewster](https://www.brewster.com), which supported the 0.x
574
575
  releases of Cequel.
@@ -23,6 +23,8 @@ module Cequel
23
23
  attr_reader :port
24
24
  # @return Integer maximum number of retries to reconnect to Cassandra
25
25
  attr_reader :max_retries
26
+ # @return Float delay between retries to reconnect to Cassandra
27
+ attr_reader :retry_delay
26
28
  # @return [Symbol] the default consistency for queries in this keyspace
27
29
  # @since 1.1.0
28
30
  attr_writer :default_consistency
@@ -121,6 +123,7 @@ module Cequel
121
123
  @hosts, @port = extract_hosts_and_port(configuration)
122
124
  @credentials = extract_credentials(configuration)
123
125
  @max_retries = extract_max_retries(configuration)
126
+ @retry_delay = extract_retry_delay(configuration)
124
127
 
125
128
  @name = configuration[:keyspace]
126
129
  @default_consistency = configuration[:default_consistency].try(:to_sym)
@@ -171,16 +174,7 @@ module Cequel
171
174
  # @see #execute_with_consistency
172
175
  #
173
176
  def execute(statement, *bind_vars)
174
- retries = max_retries
175
-
176
- begin
177
- execute_with_consistency(statement, bind_vars, default_consistency)
178
- rescue Cql::NotConnectedError, Ione::Io::ConnectionError
179
- clear_active_connections!
180
- raise if retries < 0
181
- retries -= 1
182
- retry
183
- end
177
+ execute_with_consistency(statement, bind_vars, default_consistency)
184
178
  end
185
179
 
186
180
  #
@@ -194,9 +188,19 @@ module Cequel
194
188
  # @since 1.1.0
195
189
  #
196
190
  def execute_with_consistency(statement, bind_vars, consistency)
191
+ retries = max_retries
192
+
197
193
  log('CQL', statement, *bind_vars) do
198
- client.execute(sanitize(statement, bind_vars),
199
- consistency || default_consistency)
194
+ begin
195
+ client.execute(sanitize(statement, bind_vars),
196
+ consistency || default_consistency)
197
+ rescue Cql::NotConnectedError, Ione::Io::ConnectionError
198
+ clear_active_connections!
199
+ raise if retries == 0
200
+ retries -= 1
201
+ sleep(retry_delay)
202
+ retry
203
+ end
200
204
  end
201
205
  end
202
206
 
@@ -209,6 +213,9 @@ module Cequel
209
213
  if defined? @client
210
214
  remove_instance_variable(:@client)
211
215
  end
216
+ if defined? @raw_client
217
+ remove_instance_variable(:@raw_client)
218
+ end
212
219
  end
213
220
 
214
221
  #
@@ -293,6 +300,10 @@ module Cequel
293
300
  def extract_max_retries(configuration)
294
301
  configuration.fetch(:max_retries, 3)
295
302
  end
303
+
304
+ def extract_retry_delay(configuration)
305
+ configuration.fetch(:retry_delay, 0.5)
306
+ end
296
307
  end
297
308
  end
298
309
  end
@@ -1,5 +1,5 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  module Cequel
3
3
  # The current version of the library
4
- VERSION = '1.4.4'
4
+ VERSION = '1.4.5'
5
5
  end
@@ -97,8 +97,8 @@ describe Cequel::Metal::Keyspace do
97
97
 
98
98
  context "with a connection error" do
99
99
  it "reconnects to cassandra with a new client after first failed connection" do
100
- allow(cequel.client).to receive(:execute_with_consistency)
101
- .with(statement, [], nil)
100
+ allow(cequel.client).to receive(:execute)
101
+ .with(statement, cequel.default_consistency)
102
102
  .and_raise(Ione::Io::ConnectionError)
103
103
  .once
104
104
 
@@ -4,12 +4,14 @@ development:
4
4
  port: 9042
5
5
  keyspace: <%= app_name %>_development
6
6
  max_retries: 3
7
+ retry_delay: 0.5
7
8
 
8
9
  test:
9
10
  host: '127.0.0.1'
10
11
  port: 9042
11
12
  keyspace: <%= app_name %>_test
12
13
  max_retries: 3
14
+ retry_delay: 0.5
13
15
 
14
16
  production:
15
17
  hosts:
@@ -21,3 +23,4 @@ production:
21
23
  username: 'myappuser'
22
24
  password: 'password1'
23
25
  max_retries: 3
26
+ retry_delay: 0.5
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cequel
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.4
4
+ version: 1.4.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mat Brown
@@ -22,10 +22,11 @@ authors:
22
22
  - Tomohiro Nishimura
23
23
  - Masaki Takahashi
24
24
  - G Gordon Worley III
25
+ - Clark Bremer
25
26
  autorequire:
26
27
  bindir: bin
27
28
  cert_chain: []
28
- date: 2014-10-08 00:00:00.000000000 Z
29
+ date: 2014-10-16 00:00:00.000000000 Z
29
30
  dependencies:
30
31
  - !ruby/object:Gem::Dependency
31
32
  name: activemodel