whi-cassie 1.3.0 → 1.3.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/continuous_integration.yml +21 -6
- data/HISTORY.md +18 -0
- data/VERSION +1 -1
- data/lib/cassie.rb +23 -8
- data/spec/cassie/model_spec.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: da71885a1923c8c8d801ae3312151406ec78630237c43f9057c4abc6970626cd
|
4
|
+
data.tar.gz: a4ac1795d699b89efac12f4c5455d84095dacfe07d5634754a3ac8e129d8553f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 55c5506a91a5a6cc353d64ca12a0a57bb6cd691a1f4314e257fc468cfb0bdd12b60a590a1663a2cd3b200ca9da8891c80de6cd43c4b0fc12910ca155a96cead3
|
7
|
+
data.tar.gz: 07463a9d5b35522559405d8c94f35cd4c922e2c59e7bf62fc2cc99a91d3ff22503f9900ece00fa4ffec0d050fa5c2712b8da90b150b99d6b6eb6a0c6f02bcc00
|
@@ -13,18 +13,34 @@ env:
|
|
13
13
|
BUNDLE_JOBS: 3
|
14
14
|
BUNDLE_RETRY: 3
|
15
15
|
jobs:
|
16
|
+
standard:
|
17
|
+
name: StandardRB
|
18
|
+
runs-on: ubuntu-latest
|
19
|
+
steps:
|
20
|
+
- name: checkout
|
21
|
+
uses: actions/checkout@v2
|
22
|
+
- name: set up Ruby
|
23
|
+
uses: ruby/setup-ruby@v1
|
24
|
+
with:
|
25
|
+
ruby-version: 3.0
|
26
|
+
- name: install dependencies
|
27
|
+
run: bundle install
|
28
|
+
- name: standardrb
|
29
|
+
if: matrix.job == 'standardrb'
|
30
|
+
run: bundle exec rake standard
|
31
|
+
|
16
32
|
specs:
|
17
33
|
name: ${{ matrix.job }} ruby-${{ matrix.ruby }} ${{ matrix.activemodel && format('activemodel-{0}', matrix.activemodel) }} cassandra-${{ matrix.cassandra_version }}
|
18
34
|
runs-on: ubuntu-latest
|
19
35
|
services:
|
20
36
|
cassandra:
|
21
|
-
image: cassandra:${{ matrix.cassandra_version }}
|
37
|
+
image: cassandra:${{ matrix.cassandra_version || 'latest' }}
|
22
38
|
ports:
|
23
39
|
- 9042:9042
|
24
40
|
strategy:
|
25
41
|
fail-fast: false
|
26
42
|
matrix:
|
27
|
-
ruby: ["3.
|
43
|
+
ruby: ["3.1"]
|
28
44
|
activemodel: ["original"]
|
29
45
|
job: [rspec]
|
30
46
|
cassandra_version: ["latest"]
|
@@ -39,8 +55,10 @@ jobs:
|
|
39
55
|
cassandra_version: "2"
|
40
56
|
- ruby: "2.7"
|
41
57
|
activemodel: "6"
|
58
|
+
job: rspec
|
42
59
|
- ruby: "3.0"
|
43
|
-
|
60
|
+
activemodel: "7"
|
61
|
+
job: rspec
|
44
62
|
steps:
|
45
63
|
- name: checkout
|
46
64
|
uses: actions/checkout@v2
|
@@ -59,6 +77,3 @@ jobs:
|
|
59
77
|
- name: specs
|
60
78
|
if: matrix.job == 'rspec'
|
61
79
|
run: bundle exec rake spec
|
62
|
-
- name: standardrb
|
63
|
-
if: matrix.job == 'standardrb'
|
64
|
-
run: bundle exec rake standard
|
data/HISTORY.md
CHANGED
@@ -1,3 +1,21 @@
|
|
1
|
+
## 1.3.4
|
2
|
+
|
3
|
+
* Fix syntax error.
|
4
|
+
|
5
|
+
## 1.3.3 (yanked)
|
6
|
+
|
7
|
+
* Restore automatic reconnect on dead connections.
|
8
|
+
* Handle race condition on reconnect logic.
|
9
|
+
|
10
|
+
## 1.3.2
|
11
|
+
|
12
|
+
* Improved synchronization on reconnect logic.
|
13
|
+
|
14
|
+
## 1.3.1
|
15
|
+
|
16
|
+
* Remove automatic reconnect on I/O errors.
|
17
|
+
* Handle race condition on connecting when already connected.
|
18
|
+
|
1
19
|
## 1.3.0
|
2
20
|
|
3
21
|
* Add update, update!, primary_key, and reload methods to models.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.3.
|
1
|
+
1.3.4
|
data/lib/cassie.rb
CHANGED
@@ -102,19 +102,23 @@ class Cassie
|
|
102
102
|
cluster = Cassandra.cluster(cluster_config)
|
103
103
|
logger&.info("Cassie.connect with #{config.sanitized_cluster} in #{((Time.now - start_time) * 1000).round}ms")
|
104
104
|
@monitor.synchronize do
|
105
|
-
@session
|
106
|
-
|
105
|
+
unless @session
|
106
|
+
@session = cluster.connect(config.default_keyspace)
|
107
|
+
@prepared_statements = {}
|
108
|
+
end
|
107
109
|
end
|
108
110
|
end
|
109
111
|
|
110
112
|
# Close the connections to the Cassandra cluster.
|
111
113
|
def disconnect
|
112
114
|
logger&.info("Cassie.disconnect from #{config.sanitized_cluster}")
|
115
|
+
old_session = nil
|
113
116
|
@monitor.synchronize do
|
114
|
-
@session
|
117
|
+
old_session = @session
|
115
118
|
@session = nil
|
116
119
|
@prepared_statements = {}
|
117
120
|
end
|
121
|
+
old_session&.close
|
118
122
|
end
|
119
123
|
|
120
124
|
# Return true if the connection to the Cassandra cluster has been established.
|
@@ -125,8 +129,13 @@ class Cassie
|
|
125
129
|
# Force reconnection. If you're using this code in conjunction in a forking server environment
|
126
130
|
# like passenger or unicorn you should call this method after forking.
|
127
131
|
def reconnect
|
128
|
-
|
129
|
-
|
132
|
+
existing_session = @session
|
133
|
+
@monitor.synchronize do
|
134
|
+
if @session == existing_session
|
135
|
+
disconnect
|
136
|
+
connect
|
137
|
+
end
|
138
|
+
end
|
130
139
|
end
|
131
140
|
|
132
141
|
# Prepare a CQL statement for repeate execution. Prepared statements
|
@@ -307,8 +316,8 @@ class Cassie
|
|
307
316
|
end
|
308
317
|
|
309
318
|
session.execute(statement, options || {})
|
310
|
-
rescue Cassandra::Errors::
|
311
|
-
|
319
|
+
rescue Cassandra::Errors::NoHostsAvailable => e
|
320
|
+
reconnect
|
312
321
|
raise e
|
313
322
|
ensure
|
314
323
|
if statement.is_a?(Cassandra::Statement) && !subscribers.empty?
|
@@ -330,7 +339,13 @@ class Cassie
|
|
330
339
|
end
|
331
340
|
|
332
341
|
def session
|
333
|
-
|
342
|
+
unless connected?
|
343
|
+
# Check again inside the monitor lock so we don't get in a race condition
|
344
|
+
# where another thread has already established the connection.
|
345
|
+
@monitor.synchronize do
|
346
|
+
connect unless connected?
|
347
|
+
end
|
348
|
+
end
|
334
349
|
@session
|
335
350
|
end
|
336
351
|
|
data/spec/cassie/model_spec.rb
CHANGED
@@ -133,7 +133,7 @@ describe Cassie::Model do
|
|
133
133
|
describe "batch" do
|
134
134
|
it "should delegate to Cassie.batch using the write consistency" do
|
135
135
|
expect(Cassie::Thing.connection).to be_a(Cassie)
|
136
|
-
expect(Cassie::Thing.connection).to receive(:batch).
|
136
|
+
expect(Cassie::Thing.connection).to receive(:batch).and_call_original
|
137
137
|
Cassie::Thing.batch {}
|
138
138
|
end
|
139
139
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: whi-cassie
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- We Heart It
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2022-
|
12
|
+
date: 2022-05-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: cassandra-driver
|