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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 38924e7460050a72c231a359a4a07e1695349b55d24868ae8332a0ecbcf61356
4
- data.tar.gz: 69f5b3396cb45c8f3247ba377d456173ac114220b2247163bc74060e9cff921a
3
+ metadata.gz: da71885a1923c8c8d801ae3312151406ec78630237c43f9057c4abc6970626cd
4
+ data.tar.gz: a4ac1795d699b89efac12f4c5455d84095dacfe07d5634754a3ac8e129d8553f
5
5
  SHA512:
6
- metadata.gz: 46242596cf88a2d0600be23bb25a5138c7090acc952ccdbab3344d36abb1cd94ef4aef85bae071f60275297f10571377704a7de7348875cd0984439c7a3aecfd
7
- data.tar.gz: d6e68b1ffd9a28cb27984e01bbce135502b4107d50be350d275dd745375fb5a2b90efa5384a4578c250654674b0ae7512bfe529fe3dc21f52c59b37b87e390e3
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.0"]
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
- job: standardrb
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.0
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 = cluster.connect(config.default_keyspace)
106
- @prepared_statements = {}
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&.close
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
- disconnect
129
- connect
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::IOError => e
311
- disconnect
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
- connect unless connected?
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
 
@@ -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).with(consistency: :quorum).and_call_original
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.0
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-03-04 00:00:00.000000000 Z
12
+ date: 2022-05-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: cassandra-driver