cql-rb 2.0.0.pre0 → 2.0.0.pre1

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.
Files changed (107) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +14 -2
  3. data/lib/cql.rb +8 -3
  4. data/lib/cql/client.rb +21 -356
  5. data/lib/cql/client/authenticators.rb +70 -0
  6. data/lib/cql/client/batch.rb +54 -0
  7. data/lib/cql/client/{asynchronous_client.rb → client.rb} +241 -6
  8. data/lib/cql/client/connector.rb +3 -2
  9. data/lib/cql/client/{asynchronous_prepared_statement.rb → prepared_statement.rb} +103 -0
  10. data/lib/cql/protocol.rb +1 -2
  11. data/lib/cql/protocol/cql_byte_buffer.rb +285 -0
  12. data/lib/cql/protocol/cql_protocol_handler.rb +3 -3
  13. data/lib/cql/protocol/frame_decoder.rb +3 -3
  14. data/lib/cql/protocol/frame_encoder.rb +2 -2
  15. data/lib/cql/protocol/request.rb +0 -2
  16. data/lib/cql/protocol/requests/auth_response_request.rb +2 -2
  17. data/lib/cql/protocol/requests/batch_request.rb +10 -10
  18. data/lib/cql/protocol/requests/credentials_request.rb +2 -2
  19. data/lib/cql/protocol/requests/execute_request.rb +13 -13
  20. data/lib/cql/protocol/requests/options_request.rb +2 -2
  21. data/lib/cql/protocol/requests/prepare_request.rb +2 -2
  22. data/lib/cql/protocol/requests/query_request.rb +13 -13
  23. data/lib/cql/protocol/requests/register_request.rb +2 -2
  24. data/lib/cql/protocol/requests/startup_request.rb +2 -2
  25. data/lib/cql/protocol/response.rb +2 -4
  26. data/lib/cql/protocol/responses/auth_challenge_response.rb +2 -2
  27. data/lib/cql/protocol/responses/auth_success_response.rb +2 -2
  28. data/lib/cql/protocol/responses/authenticate_response.rb +2 -2
  29. data/lib/cql/protocol/responses/detailed_error_response.rb +15 -15
  30. data/lib/cql/protocol/responses/error_response.rb +4 -4
  31. data/lib/cql/protocol/responses/event_response.rb +3 -3
  32. data/lib/cql/protocol/responses/prepared_result_response.rb +4 -4
  33. data/lib/cql/protocol/responses/raw_rows_result_response.rb +1 -1
  34. data/lib/cql/protocol/responses/ready_response.rb +1 -1
  35. data/lib/cql/protocol/responses/result_response.rb +3 -3
  36. data/lib/cql/protocol/responses/rows_result_response.rb +22 -22
  37. data/lib/cql/protocol/responses/schema_change_event_response.rb +2 -2
  38. data/lib/cql/protocol/responses/schema_change_result_response.rb +2 -2
  39. data/lib/cql/protocol/responses/set_keyspace_result_response.rb +2 -2
  40. data/lib/cql/protocol/responses/status_change_event_response.rb +2 -2
  41. data/lib/cql/protocol/responses/supported_response.rb +2 -2
  42. data/lib/cql/protocol/responses/void_result_response.rb +1 -1
  43. data/lib/cql/protocol/type_converter.rb +78 -81
  44. data/lib/cql/time_uuid.rb +6 -0
  45. data/lib/cql/uuid.rb +2 -1
  46. data/lib/cql/version.rb +1 -1
  47. data/spec/cql/client/batch_spec.rb +8 -8
  48. data/spec/cql/client/{asynchronous_client_spec.rb → client_spec.rb} +162 -0
  49. data/spec/cql/client/connector_spec.rb +13 -3
  50. data/spec/cql/client/{asynchronous_prepared_statement_spec.rb → prepared_statement_spec.rb} +148 -1
  51. data/spec/cql/client/request_runner_spec.rb +2 -2
  52. data/spec/cql/protocol/cql_byte_buffer_spec.rb +895 -0
  53. data/spec/cql/protocol/cql_protocol_handler_spec.rb +1 -1
  54. data/spec/cql/protocol/frame_decoder_spec.rb +14 -14
  55. data/spec/cql/protocol/frame_encoder_spec.rb +7 -7
  56. data/spec/cql/protocol/requests/auth_response_request_spec.rb +4 -4
  57. data/spec/cql/protocol/requests/batch_request_spec.rb +21 -21
  58. data/spec/cql/protocol/requests/credentials_request_spec.rb +2 -2
  59. data/spec/cql/protocol/requests/execute_request_spec.rb +13 -13
  60. data/spec/cql/protocol/requests/options_request_spec.rb +1 -1
  61. data/spec/cql/protocol/requests/prepare_request_spec.rb +2 -2
  62. data/spec/cql/protocol/requests/query_request_spec.rb +13 -13
  63. data/spec/cql/protocol/requests/register_request_spec.rb +2 -2
  64. data/spec/cql/protocol/requests/startup_request_spec.rb +4 -4
  65. data/spec/cql/protocol/responses/auth_challenge_response_spec.rb +5 -5
  66. data/spec/cql/protocol/responses/auth_success_response_spec.rb +5 -5
  67. data/spec/cql/protocol/responses/authenticate_response_spec.rb +3 -3
  68. data/spec/cql/protocol/responses/detailed_error_response_spec.rb +15 -15
  69. data/spec/cql/protocol/responses/error_response_spec.rb +5 -5
  70. data/spec/cql/protocol/responses/event_response_spec.rb +8 -8
  71. data/spec/cql/protocol/responses/prepared_result_response_spec.rb +7 -7
  72. data/spec/cql/protocol/responses/raw_rows_result_response_spec.rb +1 -1
  73. data/spec/cql/protocol/responses/ready_response_spec.rb +2 -2
  74. data/spec/cql/protocol/responses/result_response_spec.rb +16 -16
  75. data/spec/cql/protocol/responses/rows_result_response_spec.rb +21 -21
  76. data/spec/cql/protocol/responses/schema_change_event_response_spec.rb +3 -3
  77. data/spec/cql/protocol/responses/schema_change_result_response_spec.rb +3 -3
  78. data/spec/cql/protocol/responses/set_keyspace_result_response_spec.rb +2 -2
  79. data/spec/cql/protocol/responses/status_change_event_response_spec.rb +3 -3
  80. data/spec/cql/protocol/responses/supported_response_spec.rb +3 -3
  81. data/spec/cql/protocol/responses/topology_change_event_response_spec.rb +3 -3
  82. data/spec/cql/protocol/responses/void_result_response_spec.rb +2 -2
  83. data/spec/cql/protocol/type_converter_spec.rb +25 -13
  84. data/spec/cql/time_uuid_spec.rb +17 -4
  85. data/spec/cql/uuid_spec.rb +5 -1
  86. data/spec/integration/protocol_spec.rb +48 -42
  87. data/spec/spec_helper.rb +0 -1
  88. metadata +27 -39
  89. data/lib/cql/byte_buffer.rb +0 -177
  90. data/lib/cql/client/synchronous_client.rb +0 -79
  91. data/lib/cql/client/synchronous_prepared_statement.rb +0 -63
  92. data/lib/cql/future.rb +0 -515
  93. data/lib/cql/io.rb +0 -15
  94. data/lib/cql/io/connection.rb +0 -220
  95. data/lib/cql/io/io_reactor.rb +0 -349
  96. data/lib/cql/protocol/decoding.rb +0 -187
  97. data/lib/cql/protocol/encoding.rb +0 -114
  98. data/spec/cql/byte_buffer_spec.rb +0 -337
  99. data/spec/cql/client/synchronous_client_spec.rb +0 -170
  100. data/spec/cql/client/synchronous_prepared_statement_spec.rb +0 -155
  101. data/spec/cql/future_spec.rb +0 -737
  102. data/spec/cql/io/connection_spec.rb +0 -484
  103. data/spec/cql/io/io_reactor_spec.rb +0 -402
  104. data/spec/cql/protocol/decoding_spec.rb +0 -547
  105. data/spec/cql/protocol/encoding_spec.rb +0 -386
  106. data/spec/integration/io_spec.rb +0 -283
  107. data/spec/support/fake_server.rb +0 -106
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cql-rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0.pre0
4
+ version: 2.0.0.pre1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Theo Hultberg
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-13 00:00:00.000000000 Z
12
- dependencies: []
11
+ date: 2014-03-15 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: ione
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  description: A pure Ruby CQL3 driver for Cassandra
14
28
  email:
15
29
  - theo@iconara.net
@@ -20,12 +34,10 @@ files:
20
34
  - .yardopts
21
35
  - README.md
22
36
  - lib/cql.rb
23
- - lib/cql/byte_buffer.rb
24
37
  - lib/cql/client.rb
25
- - lib/cql/client/asynchronous_client.rb
26
- - lib/cql/client/asynchronous_prepared_statement.rb
27
38
  - lib/cql/client/authenticators.rb
28
39
  - lib/cql/client/batch.rb
40
+ - lib/cql/client/client.rb
29
41
  - lib/cql/client/column_metadata.rb
30
42
  - lib/cql/client/connection_manager.rb
31
43
  - lib/cql/client/connector.rb
@@ -33,23 +45,17 @@ files:
33
45
  - lib/cql/client/keyspace_changer.rb
34
46
  - lib/cql/client/null_logger.rb
35
47
  - lib/cql/client/peer_discovery.rb
48
+ - lib/cql/client/prepared_statement.rb
36
49
  - lib/cql/client/query_result.rb
37
50
  - lib/cql/client/query_trace.rb
38
51
  - lib/cql/client/request_runner.rb
39
52
  - lib/cql/client/result_metadata.rb
40
- - lib/cql/client/synchronous_client.rb
41
- - lib/cql/client/synchronous_prepared_statement.rb
42
53
  - lib/cql/client/void_result.rb
43
54
  - lib/cql/compression.rb
44
55
  - lib/cql/compression/snappy_compressor.rb
45
- - lib/cql/future.rb
46
- - lib/cql/io.rb
47
- - lib/cql/io/connection.rb
48
- - lib/cql/io/io_reactor.rb
49
56
  - lib/cql/protocol.rb
57
+ - lib/cql/protocol/cql_byte_buffer.rb
50
58
  - lib/cql/protocol/cql_protocol_handler.rb
51
- - lib/cql/protocol/decoding.rb
52
- - lib/cql/protocol/encoding.rb
53
59
  - lib/cql/protocol/frame_decoder.rb
54
60
  - lib/cql/protocol/frame_encoder.rb
55
61
  - lib/cql/protocol/request.rb
@@ -85,31 +91,24 @@ files:
85
91
  - lib/cql/time_uuid.rb
86
92
  - lib/cql/uuid.rb
87
93
  - lib/cql/version.rb
88
- - spec/cql/byte_buffer_spec.rb
89
- - spec/cql/client/asynchronous_client_spec.rb
90
- - spec/cql/client/asynchronous_prepared_statement_spec.rb
91
94
  - spec/cql/client/authenticators_spec.rb
92
95
  - spec/cql/client/batch_spec.rb
96
+ - spec/cql/client/client_spec.rb
93
97
  - spec/cql/client/column_metadata_spec.rb
94
98
  - spec/cql/client/connection_manager_spec.rb
95
99
  - spec/cql/client/connector_spec.rb
96
100
  - spec/cql/client/execute_options_decoder_spec.rb
97
101
  - spec/cql/client/keyspace_changer_spec.rb
98
102
  - spec/cql/client/peer_discovery_spec.rb
103
+ - spec/cql/client/prepared_statement_spec.rb
99
104
  - spec/cql/client/query_result_spec.rb
100
105
  - spec/cql/client/query_trace_spec.rb
101
106
  - spec/cql/client/request_runner_spec.rb
102
- - spec/cql/client/synchronous_client_spec.rb
103
- - spec/cql/client/synchronous_prepared_statement_spec.rb
104
107
  - spec/cql/client/void_result_spec.rb
105
108
  - spec/cql/compression/compression_common.rb
106
109
  - spec/cql/compression/snappy_compressor_spec.rb
107
- - spec/cql/future_spec.rb
108
- - spec/cql/io/connection_spec.rb
109
- - spec/cql/io/io_reactor_spec.rb
110
+ - spec/cql/protocol/cql_byte_buffer_spec.rb
110
111
  - spec/cql/protocol/cql_protocol_handler_spec.rb
111
- - spec/cql/protocol/decoding_spec.rb
112
- - spec/cql/protocol/encoding_spec.rb
113
112
  - spec/cql/protocol/frame_decoder_spec.rb
114
113
  - spec/cql/protocol/frame_encoder_spec.rb
115
114
  - spec/cql/protocol/requests/auth_response_request_spec.rb
@@ -143,7 +142,6 @@ files:
143
142
  - spec/cql/time_uuid_spec.rb
144
143
  - spec/cql/uuid_spec.rb
145
144
  - spec/integration/client_spec.rb
146
- - spec/integration/io_spec.rb
147
145
  - spec/integration/protocol_spec.rb
148
146
  - spec/integration/regression_spec.rb
149
147
  - spec/integration/uuid_spec.rb
@@ -151,7 +149,6 @@ files:
151
149
  - spec/support/await_helper.rb
152
150
  - spec/support/bytes_helper.rb
153
151
  - spec/support/fake_io_reactor.rb
154
- - spec/support/fake_server.rb
155
152
  homepage: http://github.com/iconara/cql-rb
156
153
  licenses:
157
154
  - Apache License 2.0
@@ -164,7 +161,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
164
161
  requirements:
165
162
  - - '>='
166
163
  - !ruby/object:Gem::Version
167
- version: 1.9.2
164
+ version: 1.9.3
168
165
  required_rubygems_version: !ruby/object:Gem::Requirement
169
166
  requirements:
170
167
  - - '>'
@@ -177,31 +174,24 @@ signing_key:
177
174
  specification_version: 4
178
175
  summary: Cassandra CQL3 driver
179
176
  test_files:
180
- - spec/cql/byte_buffer_spec.rb
181
- - spec/cql/client/asynchronous_client_spec.rb
182
- - spec/cql/client/asynchronous_prepared_statement_spec.rb
183
177
  - spec/cql/client/authenticators_spec.rb
184
178
  - spec/cql/client/batch_spec.rb
179
+ - spec/cql/client/client_spec.rb
185
180
  - spec/cql/client/column_metadata_spec.rb
186
181
  - spec/cql/client/connection_manager_spec.rb
187
182
  - spec/cql/client/connector_spec.rb
188
183
  - spec/cql/client/execute_options_decoder_spec.rb
189
184
  - spec/cql/client/keyspace_changer_spec.rb
190
185
  - spec/cql/client/peer_discovery_spec.rb
186
+ - spec/cql/client/prepared_statement_spec.rb
191
187
  - spec/cql/client/query_result_spec.rb
192
188
  - spec/cql/client/query_trace_spec.rb
193
189
  - spec/cql/client/request_runner_spec.rb
194
- - spec/cql/client/synchronous_client_spec.rb
195
- - spec/cql/client/synchronous_prepared_statement_spec.rb
196
190
  - spec/cql/client/void_result_spec.rb
197
191
  - spec/cql/compression/compression_common.rb
198
192
  - spec/cql/compression/snappy_compressor_spec.rb
199
- - spec/cql/future_spec.rb
200
- - spec/cql/io/connection_spec.rb
201
- - spec/cql/io/io_reactor_spec.rb
193
+ - spec/cql/protocol/cql_byte_buffer_spec.rb
202
194
  - spec/cql/protocol/cql_protocol_handler_spec.rb
203
- - spec/cql/protocol/decoding_spec.rb
204
- - spec/cql/protocol/encoding_spec.rb
205
195
  - spec/cql/protocol/frame_decoder_spec.rb
206
196
  - spec/cql/protocol/frame_encoder_spec.rb
207
197
  - spec/cql/protocol/requests/auth_response_request_spec.rb
@@ -235,7 +225,6 @@ test_files:
235
225
  - spec/cql/time_uuid_spec.rb
236
226
  - spec/cql/uuid_spec.rb
237
227
  - spec/integration/client_spec.rb
238
- - spec/integration/io_spec.rb
239
228
  - spec/integration/protocol_spec.rb
240
229
  - spec/integration/regression_spec.rb
241
230
  - spec/integration/uuid_spec.rb
@@ -243,5 +232,4 @@ test_files:
243
232
  - spec/support/await_helper.rb
244
233
  - spec/support/bytes_helper.rb
245
234
  - spec/support/fake_io_reactor.rb
246
- - spec/support/fake_server.rb
247
235
  has_rdoc:
@@ -1,177 +0,0 @@
1
- # encoding: utf-8
2
-
3
- module Cql
4
- # @private
5
- class ByteBuffer
6
- def initialize(initial_bytes='')
7
- @read_buffer = ''
8
- @write_buffer = ''
9
- @offset = 0
10
- @length = 0
11
- append(initial_bytes) unless initial_bytes.empty?
12
- end
13
-
14
- attr_reader :length
15
- alias_method :size, :length
16
- alias_method :bytesize, :length
17
-
18
- def empty?
19
- length == 0
20
- end
21
-
22
- def append(bytes)
23
- if bytes.is_a?(self.class)
24
- bytes.append_to(self)
25
- else
26
- bytes = bytes.to_s
27
- unless bytes.ascii_only?
28
- bytes = bytes.dup.force_encoding(::Encoding::BINARY)
29
- end
30
- retag = @write_buffer.empty?
31
- @write_buffer << bytes
32
- @write_buffer.force_encoding(::Encoding::BINARY) if retag
33
- @length += bytes.bytesize
34
- end
35
- self
36
- end
37
- alias_method :<<, :append
38
-
39
- def discard(n)
40
- raise RangeError, "#{n} bytes to discard but only #{@length} available" if @length < n
41
- @offset += n
42
- @length -= n
43
- self
44
- end
45
-
46
- def read(n)
47
- raise RangeError, "#{n} bytes required but only #{@length} available" if @length < n
48
- if @offset >= @read_buffer.bytesize
49
- swap_buffers
50
- end
51
- if @offset + n > @read_buffer.bytesize
52
- s = read(@read_buffer.bytesize - @offset)
53
- s << read(n - s.bytesize)
54
- s
55
- else
56
- s = @read_buffer[@offset, n]
57
- @offset += n
58
- @length -= n
59
- s
60
- end
61
- end
62
-
63
- def read_int
64
- raise RangeError, "4 bytes required to read an int, but only #{@length} available" if @length < 4
65
- if @offset >= @read_buffer.bytesize
66
- swap_buffers
67
- end
68
- if @read_buffer.bytesize >= @offset + 4
69
- i0 = @read_buffer.getbyte(@offset + 0)
70
- i1 = @read_buffer.getbyte(@offset + 1)
71
- i2 = @read_buffer.getbyte(@offset + 2)
72
- i3 = @read_buffer.getbyte(@offset + 3)
73
- @offset += 4
74
- @length -= 4
75
- else
76
- i0 = read_byte
77
- i1 = read_byte
78
- i2 = read_byte
79
- i3 = read_byte
80
- end
81
- (i0 << 24) | (i1 << 16) | (i2 << 8) | i3
82
- end
83
-
84
- def read_short
85
- raise RangeError, "2 bytes required to read a short, but only #{@length} available" if @length < 2
86
- if @offset >= @read_buffer.bytesize
87
- swap_buffers
88
- end
89
- if @read_buffer.bytesize >= @offset + 2
90
- i0 = @read_buffer.getbyte(@offset + 0)
91
- i1 = @read_buffer.getbyte(@offset + 1)
92
- @offset += 2
93
- @length -= 2
94
- else
95
- i0 = read_byte
96
- i1 = read_byte
97
- end
98
- (i0 << 8) | i1
99
- end
100
-
101
- def read_byte(signed=false)
102
- raise RangeError, "No bytes available to read byte" if empty?
103
- if @offset >= @read_buffer.bytesize
104
- swap_buffers
105
- end
106
- b = @read_buffer.getbyte(@offset)
107
- b = (b & 0x7f) - (b & 0x80) if signed
108
- @offset += 1
109
- @length -= 1
110
- b
111
- end
112
-
113
- def update(location, bytes)
114
- absolute_offset = @offset + location
115
- bytes_length = bytes.bytesize
116
- if absolute_offset >= @read_buffer.bytesize
117
- @write_buffer[absolute_offset - @read_buffer.bytesize, bytes_length] = bytes
118
- else
119
- overflow = absolute_offset + bytes_length - @read_buffer.bytesize
120
- read_buffer_portion = bytes_length - overflow
121
- @read_buffer[absolute_offset, read_buffer_portion] = bytes[0, read_buffer_portion]
122
- if overflow > 0
123
- @write_buffer[0, overflow] = bytes[read_buffer_portion, bytes_length - 1]
124
- end
125
- end
126
- end
127
-
128
- def cheap_peek
129
- if @offset >= @read_buffer.bytesize
130
- swap_buffers
131
- end
132
- @read_buffer[@offset, @read_buffer.bytesize - @offset]
133
- end
134
-
135
- def eql?(other)
136
- self.to_str.eql?(other.to_str)
137
- end
138
- alias_method :==, :eql?
139
-
140
- def hash
141
- to_str.hash
142
- end
143
-
144
- def dup
145
- self.class.new(to_str)
146
- end
147
-
148
- def to_str
149
- (@read_buffer + @write_buffer)[@offset, @length]
150
- end
151
- alias_method :to_s, :to_str
152
-
153
- def inspect
154
- %(#<#{self.class.name}: #{to_str.inspect}>)
155
- end
156
-
157
- protected
158
-
159
- def append_to(other)
160
- other.raw_append(cheap_peek)
161
- other.raw_append(@write_buffer) unless @write_buffer.empty?
162
- end
163
-
164
- def raw_append(bytes)
165
- @write_buffer << bytes
166
- @length += bytes.bytesize
167
- end
168
-
169
- private
170
-
171
- def swap_buffers
172
- @offset -= @read_buffer.bytesize
173
- @read_buffer = @write_buffer
174
- @write_buffer = ''
175
- end
176
- end
177
- end
@@ -1,79 +0,0 @@
1
- # encoding: utf-8
2
-
3
- module Cql
4
- module Client
5
- # @private
6
- module SynchronousBacktrace
7
- def synchronous_backtrace
8
- yield
9
- rescue CqlError => e
10
- new_backtrace = caller
11
- if new_backtrace.first.include?(SYNCHRONOUS_BACKTRACE_METHOD_NAME)
12
- new_backtrace = new_backtrace.drop(1)
13
- end
14
- e.set_backtrace(new_backtrace)
15
- raise
16
- end
17
-
18
- private
19
-
20
- SYNCHRONOUS_BACKTRACE_METHOD_NAME = 'synchronous_backtrace'
21
- end
22
-
23
- # @private
24
- class SynchronousClient < Client
25
- include SynchronousBacktrace
26
-
27
- def initialize(async_client)
28
- @async_client = async_client
29
- end
30
-
31
- def connect
32
- synchronous_backtrace { @async_client.connect.value }
33
- self
34
- end
35
-
36
- def close
37
- synchronous_backtrace { @async_client.close.value }
38
- self
39
- end
40
-
41
- def connected?
42
- @async_client.connected?
43
- end
44
-
45
- def keyspace
46
- @async_client.keyspace
47
- end
48
-
49
- def use(keyspace)
50
- synchronous_backtrace { @async_client.use(keyspace).value }
51
- end
52
-
53
- def execute(cql, *args)
54
- synchronous_backtrace do
55
- result = @async_client.execute(cql, *args).value
56
- result = SynchronousPagedQueryResult.new(result) if result.is_a?(PagedQueryResult)
57
- result
58
- end
59
- end
60
-
61
- def prepare(cql)
62
- async_statement = synchronous_backtrace { @async_client.prepare(cql).value }
63
- SynchronousPreparedStatement.new(async_statement)
64
- end
65
-
66
- def batch(type=:logged, options={}, &block)
67
- if block_given?
68
- synchronous_backtrace { @async_client.batch(type, options, &block).value }
69
- else
70
- SynchronousBatch.new(@async_client.batch(type, options))
71
- end
72
- end
73
-
74
- def async
75
- @async_client
76
- end
77
- end
78
- end
79
- end
@@ -1,63 +0,0 @@
1
- # encoding: utf-8
2
-
3
- module Cql
4
- module Client
5
- # @private
6
- class SynchronousPreparedStatement < PreparedStatement
7
- include SynchronousBacktrace
8
-
9
- def initialize(async_statement)
10
- @async_statement = async_statement
11
- @metadata = async_statement.metadata
12
- @result_metadata = async_statement.result_metadata
13
- end
14
-
15
- def execute(*args)
16
- synchronous_backtrace do
17
- result = @async_statement.execute(*args).value
18
- result = SynchronousPagedQueryResult.new(result) if result.is_a?(PagedQueryResult)
19
- result
20
- end
21
- end
22
-
23
- def batch(type=:logged, options=nil, &block)
24
- if block_given?
25
- synchronous_backtrace { @async_statement.batch(type, options, &block).value }
26
- else
27
- SynchronousPreparedStatementBatch.new(@async_statement.batch(type, options))
28
- end
29
- end
30
-
31
- def pipeline
32
- pl = Pipeline.new(@async_statement)
33
- yield pl
34
- synchronous_backtrace { pl.value }
35
- end
36
-
37
- def async
38
- @async_statement
39
- end
40
-
41
- # @private
42
- def add_to_batch(batch, connection, bound_arguments)
43
- @async_statement.add_to_batch(batch, connection, bound_arguments)
44
- end
45
- end
46
-
47
- # @private
48
- class Pipeline
49
- def initialize(async_statement)
50
- @async_statement = async_statement
51
- @futures = []
52
- end
53
-
54
- def execute(*args)
55
- @futures << @async_statement.execute(*args)
56
- end
57
-
58
- def value
59
- Future.all(*@futures).value
60
- end
61
- end
62
- end
63
- end