cequel 1.4.4 → 1.4.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +1 -1
- data/README.md +1 -0
- data/lib/cequel/metal/keyspace.rb +23 -12
- data/lib/cequel/version.rb +1 -1
- data/spec/examples/metal/keyspace_spec.rb +2 -2
- data/templates/config/cequel.yml +3 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4fba208e19ab7eabd8a3f2db192e68a4cc70bd48
|
4
|
+
data.tar.gz: 701fad60ff7b547719c39817abffd3b080a469a5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e94e957983915b7cb434dfdfb4cf913e47d25c687c17f2106d53730bd0624acacf74454c2ca64b29bfae5d31a8ff8bece1e1ef6dd7e19252c41e8de5dee305de
|
7
|
+
data.tar.gz: d9b7ae7438d6b188e5709357bf6c7ba21de7b0af3f26de5311290824381b4c66be2355318ac8cfe974e196f44e3b7b5ea866593adaa27d2797138db1039fa39b
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -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
|
-
|
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
|
-
|
199
|
-
|
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
|
data/lib/cequel/version.rb
CHANGED
@@ -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(:
|
101
|
-
.with(statement,
|
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
|
|
data/templates/config/cequel.yml
CHANGED
@@ -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
|
+
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-
|
29
|
+
date: 2014-10-16 00:00:00.000000000 Z
|
29
30
|
dependencies:
|
30
31
|
- !ruby/object:Gem::Dependency
|
31
32
|
name: activemodel
|