cql-rb 1.1.1 → 1.1.2

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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NzFiOTFkMzdmNTNhMzkzYzg0ZmM5ZGViZDI4NTk1OTk0NzM0NmY0Mg==
4
+ ZTJjMzQ5MTY0M2I5N2JjYzZmODFkODQwNzY3ZmE2MmU1MGZjZGUzMw==
5
5
  data.tar.gz: !binary |-
6
- MzRkNDQ2YjE0YmUyMjg0YTYyOWFhOTY4MDE2NGYwZDUwOTIxODEyOA==
6
+ N2I0MjdmODYxOTM0YjgwODFjNThhZDJmOWFlMzdiNDdjYjJmODBmNQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NGQwOWEyNzdiYTc0YThjNWNiNGMzODAwMGY3NDgwMWEwYzEzZGRhYmQ1N2Iz
10
- MDljZTkyY2EwNzE3ZTY4ZWMyMGIyZWYyZTM2MWUyMDQyMDNiY2RmYTlhODli
11
- ZTBjOTM1MmY3NGM5NDQxMDY1OTJkNWM0NDBlMDdjMjE0ZDMzY2Q=
9
+ MzE0MWU4ZTUxYmNjOGFkMDc0MzE1YTgxMGEyN2YzMzY2NDYzYTJjZTYxNDM5
10
+ ZTU3NGJiY2MxYjAyZjBjOWU3NmM1NmNiMDU2ZmI0YWYxMDUyOGI5OTQ1M2Zi
11
+ YzBkZmRmODIyMTUyZTUxMGM3MTk5YTg4MDE3YTZhODAxY2U4MjE=
12
12
  data.tar.gz: !binary |-
13
- ZjViNmJkNmQyYWIwZmQ4NGM4ZmJjMGFiYzc1NjFlZDRiYjBhZmU1ZGIxMzEw
14
- MjQwOTAzODk1YmZjMTQyMDYyNDFhZTIyNDZiYmNjNDlhZDUwZDI4MWQ1MTIx
15
- YTMwM2MwNjE0MDI4NDM5MTM5MjkyZjdkMDIyZDMxODk1NDhkYjc=
13
+ ZmMwYTY2NTU3MGZhMjMyOTk0NjhkZjRmMTA2YmU2MTVhNzYxMmRhZDkzNmU2
14
+ NWNiOTY1YmYzYjlkOGZlMTkyMDdkMzJiMjQyMzY1ZDFkNGI3ZDE4OTUyNzFj
15
+ ZTgyZWU0YzA3OTVmOWQwYjEzMDgwZTRmNmM2NDgxMjQwNDc2MTA=
@@ -54,7 +54,7 @@ require 'cql/protocol/responses/set_keyspace_result_response'
54
54
  require 'cql/protocol/responses/prepared_result_response'
55
55
  require 'cql/protocol/responses/schema_change_result_response'
56
56
  require 'cql/protocol/responses/event_response'
57
- require 'cql/protocol/responses/schema_change_event_result_response'
57
+ require 'cql/protocol/responses/schema_change_event_response'
58
58
  require 'cql/protocol/responses/status_change_event_result_response'
59
59
  require 'cql/protocol/responses/topology_change_event_result_response'
60
60
  require 'cql/protocol/request'
@@ -245,22 +245,18 @@ module Cql
245
245
 
246
246
  def socket_closed(cause)
247
247
  request_failure_cause = cause || Io::ConnectionClosedError.new
248
+ promises_to_fail = nil
248
249
  @lock.synchronize do
249
- @promises.each_with_index do |promise, i|
250
- if promise
251
- @promises[i].fail(request_failure_cause)
252
- @promises[i] = nil
253
- end
254
- end
255
- @request_queue_in.each do |promise|
256
- promise.fail(request_failure_cause)
257
- end
250
+ promises_to_fail = @promises.compact
251
+ promises_to_fail.concat(@request_queue_in)
252
+ promises_to_fail.concat(@request_queue_out)
253
+ @promises.fill(nil)
258
254
  @request_queue_in.clear
259
- @request_queue_out.each do |promise|
260
- promise.fail(request_failure_cause)
261
- end
262
255
  @request_queue_out.clear
263
256
  end
257
+ promises_to_fail.each do |promise|
258
+ promise.fail(request_failure_cause)
259
+ end
264
260
  if cause
265
261
  @closed_promise.fail(cause)
266
262
  else
@@ -5,17 +5,16 @@ module Cql
5
5
  class EventResponse < ResultResponse
6
6
  def self.decode!(buffer)
7
7
  type = read_string!(buffer)
8
- case type
9
- when SchemaChangeEventResponse::TYPE
10
- SchemaChangeEventResponse.decode!(buffer)
11
- when StatusChangeEventResponse::TYPE
12
- StatusChangeEventResponse.decode!(buffer)
13
- when TopologyChangeEventResponse::TYPE
14
- TopologyChangeEventResponse.decode!(buffer)
15
- else
16
- raise UnsupportedEventTypeError, %(Unsupported event type: "#{type}")
17
- end
8
+ impl = EVENT_TYPES[type]
9
+ raise UnsupportedEventTypeError, %(Unsupported event type: "#{type}") unless impl
10
+ impl.decode!(buffer)
18
11
  end
12
+
13
+ private
14
+
15
+ EVENT_TYPES = {
16
+ # populated by subclasses
17
+ }
19
18
  end
20
19
  end
21
20
  end
@@ -18,6 +18,10 @@ module Cql
18
18
  def to_s
19
19
  %(RESULT PREPARED #{id.each_byte.map { |x| x.to_s(16) }.join('')} #@metadata)
20
20
  end
21
+
22
+ private
23
+
24
+ RESULT_TYPES[0x04] = self
21
25
  end
22
26
  end
23
27
  end
@@ -5,25 +5,20 @@ module Cql
5
5
  class ResultResponse < Response
6
6
  def self.decode!(buffer)
7
7
  kind = read_int!(buffer)
8
- case kind
9
- when 0x01
10
- VoidResultResponse.decode!(buffer)
11
- when 0x02
12
- RowsResultResponse.decode!(buffer)
13
- when 0x03
14
- SetKeyspaceResultResponse.decode!(buffer)
15
- when 0x04
16
- PreparedResultResponse.decode!(buffer)
17
- when 0x05
18
- SchemaChangeResultResponse.decode!(buffer)
19
- else
20
- raise UnsupportedResultKindError, %(Unsupported result kind: #{kind})
21
- end
8
+ impl = RESULT_TYPES[kind]
9
+ raise UnsupportedResultKindError, %(Unsupported result kind: #{kind}) unless impl
10
+ impl.decode!(buffer)
22
11
  end
23
12
 
24
13
  def void?
25
14
  false
26
15
  end
16
+
17
+ private
18
+
19
+ RESULT_TYPES = [
20
+ # populated by subclasses
21
+ ]
27
22
  end
28
23
  end
29
24
  end
@@ -20,6 +20,8 @@ module Cql
20
20
 
21
21
  private
22
22
 
23
+ RESULT_TYPES[0x02] = self
24
+
23
25
  COLUMN_TYPES = [
24
26
  nil,
25
27
  :ascii,
@@ -35,6 +35,10 @@ module Cql
35
35
  def to_s
36
36
  %(EVENT #@type #@change "#@keyspace" "#@table")
37
37
  end
38
+
39
+ private
40
+
41
+ EVENT_TYPES[TYPE] = self
38
42
  end
39
43
  end
40
44
  end
@@ -31,6 +31,10 @@ module Cql
31
31
  def to_s
32
32
  %(RESULT SCHEMA_CHANGE #@change "#@keyspace" "#@table")
33
33
  end
34
+
35
+ private
36
+
37
+ RESULT_TYPES[0x05] = self
34
38
  end
35
39
  end
36
40
  end
@@ -16,6 +16,10 @@ module Cql
16
16
  def to_s
17
17
  %(RESULT SET_KEYSPACE "#@keyspace")
18
18
  end
19
+
20
+ private
21
+
22
+ RESULT_TYPES[0x03] = self
19
23
  end
20
24
  end
21
25
  end
@@ -19,6 +19,10 @@ module Cql
19
19
  def to_s
20
20
  %(EVENT #@type #@change #@address:#@port)
21
21
  end
22
+
23
+ private
24
+
25
+ EVENT_TYPES[TYPE] = self
22
26
  end
23
27
  end
24
28
  end
@@ -9,6 +9,10 @@ module Cql
9
9
  super
10
10
  @type = TYPE
11
11
  end
12
+
13
+ private
14
+
15
+ EVENT_TYPES[TYPE] = self
12
16
  end
13
17
  end
14
18
  end
@@ -14,6 +14,10 @@ module Cql
14
14
  def void?
15
15
  true
16
16
  end
17
+
18
+ private
19
+
20
+ RESULT_TYPES[0x01] = self
17
21
  end
18
22
  end
19
23
  end
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module Cql
4
- VERSION = '1.1.1'.freeze
4
+ VERSION = '1.1.2'.freeze
5
5
  end
@@ -25,8 +25,8 @@ describe 'A CQL client' do
25
25
  it 'knows which keyspace it\'s in' do
26
26
  client.use('system')
27
27
  client.keyspace.should == 'system'
28
- client.use('system_auth')
29
- client.keyspace.should == 'system_auth'
28
+ client.use('system_traces')
29
+ client.keyspace.should == 'system_traces'
30
30
  end
31
31
 
32
32
  it 'is not in a keyspace initially' do
@@ -142,7 +142,6 @@ describe 'Protocol parsing and communication' do
142
142
  raw_execute_request(Cql::Protocol::StartupRequest.new)
143
143
  response = raw_execute_request(Cql::Protocol::RegisterRequest.new('TOPOLOGY_CHANGE'))
144
144
  response.code.should == 10
145
- response.message.should include('needs authentication')
146
145
  end
147
146
  end
148
147
 
@@ -9,7 +9,7 @@ require 'support/await_helper'
9
9
  require 'support/fake_server'
10
10
  require 'support/fake_io_reactor'
11
11
 
12
- unless ENV['COVERAGE'] == 'no'
12
+ unless ENV['COVERAGE'] == 'no' || RUBY_ENGINE == 'rbx'
13
13
  require 'coveralls'
14
14
  require 'simplecov'
15
15
 
@@ -26,4 +26,3 @@ unless ENV['COVERAGE'] == 'no'
26
26
  end
27
27
 
28
28
  require 'cql'
29
-
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cql-rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Theo Hultberg
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-07 00:00:00.000000000 Z
11
+ date: 2013-12-14 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A pure Ruby CQL3 driver for Cassandra
14
14
  email:
@@ -57,7 +57,7 @@ files:
57
57
  - lib/cql/protocol/responses/ready_response.rb
58
58
  - lib/cql/protocol/responses/result_response.rb
59
59
  - lib/cql/protocol/responses/rows_result_response.rb
60
- - lib/cql/protocol/responses/schema_change_event_result_response.rb
60
+ - lib/cql/protocol/responses/schema_change_event_response.rb
61
61
  - lib/cql/protocol/responses/schema_change_result_response.rb
62
62
  - lib/cql/protocol/responses/set_keyspace_result_response.rb
63
63
  - lib/cql/protocol/responses/status_change_event_result_response.rb
@@ -130,7 +130,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
130
130
  version: '0'
131
131
  requirements: []
132
132
  rubyforge_project:
133
- rubygems_version: 2.1.5
133
+ rubygems_version: 2.1.11
134
134
  signing_key:
135
135
  specification_version: 4
136
136
  summary: Cassandra CQL3 driver