cql-rb 2.0.0.pre0 → 2.0.0.pre1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +14 -2
- data/lib/cql.rb +8 -3
- data/lib/cql/client.rb +21 -356
- data/lib/cql/client/authenticators.rb +70 -0
- data/lib/cql/client/batch.rb +54 -0
- data/lib/cql/client/{asynchronous_client.rb → client.rb} +241 -6
- data/lib/cql/client/connector.rb +3 -2
- data/lib/cql/client/{asynchronous_prepared_statement.rb → prepared_statement.rb} +103 -0
- data/lib/cql/protocol.rb +1 -2
- data/lib/cql/protocol/cql_byte_buffer.rb +285 -0
- data/lib/cql/protocol/cql_protocol_handler.rb +3 -3
- data/lib/cql/protocol/frame_decoder.rb +3 -3
- data/lib/cql/protocol/frame_encoder.rb +2 -2
- data/lib/cql/protocol/request.rb +0 -2
- data/lib/cql/protocol/requests/auth_response_request.rb +2 -2
- data/lib/cql/protocol/requests/batch_request.rb +10 -10
- data/lib/cql/protocol/requests/credentials_request.rb +2 -2
- data/lib/cql/protocol/requests/execute_request.rb +13 -13
- data/lib/cql/protocol/requests/options_request.rb +2 -2
- data/lib/cql/protocol/requests/prepare_request.rb +2 -2
- data/lib/cql/protocol/requests/query_request.rb +13 -13
- data/lib/cql/protocol/requests/register_request.rb +2 -2
- data/lib/cql/protocol/requests/startup_request.rb +2 -2
- data/lib/cql/protocol/response.rb +2 -4
- data/lib/cql/protocol/responses/auth_challenge_response.rb +2 -2
- data/lib/cql/protocol/responses/auth_success_response.rb +2 -2
- data/lib/cql/protocol/responses/authenticate_response.rb +2 -2
- data/lib/cql/protocol/responses/detailed_error_response.rb +15 -15
- data/lib/cql/protocol/responses/error_response.rb +4 -4
- data/lib/cql/protocol/responses/event_response.rb +3 -3
- data/lib/cql/protocol/responses/prepared_result_response.rb +4 -4
- data/lib/cql/protocol/responses/raw_rows_result_response.rb +1 -1
- data/lib/cql/protocol/responses/ready_response.rb +1 -1
- data/lib/cql/protocol/responses/result_response.rb +3 -3
- data/lib/cql/protocol/responses/rows_result_response.rb +22 -22
- data/lib/cql/protocol/responses/schema_change_event_response.rb +2 -2
- data/lib/cql/protocol/responses/schema_change_result_response.rb +2 -2
- data/lib/cql/protocol/responses/set_keyspace_result_response.rb +2 -2
- data/lib/cql/protocol/responses/status_change_event_response.rb +2 -2
- data/lib/cql/protocol/responses/supported_response.rb +2 -2
- data/lib/cql/protocol/responses/void_result_response.rb +1 -1
- data/lib/cql/protocol/type_converter.rb +78 -81
- data/lib/cql/time_uuid.rb +6 -0
- data/lib/cql/uuid.rb +2 -1
- data/lib/cql/version.rb +1 -1
- data/spec/cql/client/batch_spec.rb +8 -8
- data/spec/cql/client/{asynchronous_client_spec.rb → client_spec.rb} +162 -0
- data/spec/cql/client/connector_spec.rb +13 -3
- data/spec/cql/client/{asynchronous_prepared_statement_spec.rb → prepared_statement_spec.rb} +148 -1
- data/spec/cql/client/request_runner_spec.rb +2 -2
- data/spec/cql/protocol/cql_byte_buffer_spec.rb +895 -0
- data/spec/cql/protocol/cql_protocol_handler_spec.rb +1 -1
- data/spec/cql/protocol/frame_decoder_spec.rb +14 -14
- data/spec/cql/protocol/frame_encoder_spec.rb +7 -7
- data/spec/cql/protocol/requests/auth_response_request_spec.rb +4 -4
- data/spec/cql/protocol/requests/batch_request_spec.rb +21 -21
- data/spec/cql/protocol/requests/credentials_request_spec.rb +2 -2
- data/spec/cql/protocol/requests/execute_request_spec.rb +13 -13
- data/spec/cql/protocol/requests/options_request_spec.rb +1 -1
- data/spec/cql/protocol/requests/prepare_request_spec.rb +2 -2
- data/spec/cql/protocol/requests/query_request_spec.rb +13 -13
- data/spec/cql/protocol/requests/register_request_spec.rb +2 -2
- data/spec/cql/protocol/requests/startup_request_spec.rb +4 -4
- data/spec/cql/protocol/responses/auth_challenge_response_spec.rb +5 -5
- data/spec/cql/protocol/responses/auth_success_response_spec.rb +5 -5
- data/spec/cql/protocol/responses/authenticate_response_spec.rb +3 -3
- data/spec/cql/protocol/responses/detailed_error_response_spec.rb +15 -15
- data/spec/cql/protocol/responses/error_response_spec.rb +5 -5
- data/spec/cql/protocol/responses/event_response_spec.rb +8 -8
- data/spec/cql/protocol/responses/prepared_result_response_spec.rb +7 -7
- data/spec/cql/protocol/responses/raw_rows_result_response_spec.rb +1 -1
- data/spec/cql/protocol/responses/ready_response_spec.rb +2 -2
- data/spec/cql/protocol/responses/result_response_spec.rb +16 -16
- data/spec/cql/protocol/responses/rows_result_response_spec.rb +21 -21
- data/spec/cql/protocol/responses/schema_change_event_response_spec.rb +3 -3
- data/spec/cql/protocol/responses/schema_change_result_response_spec.rb +3 -3
- data/spec/cql/protocol/responses/set_keyspace_result_response_spec.rb +2 -2
- data/spec/cql/protocol/responses/status_change_event_response_spec.rb +3 -3
- data/spec/cql/protocol/responses/supported_response_spec.rb +3 -3
- data/spec/cql/protocol/responses/topology_change_event_response_spec.rb +3 -3
- data/spec/cql/protocol/responses/void_result_response_spec.rb +2 -2
- data/spec/cql/protocol/type_converter_spec.rb +25 -13
- data/spec/cql/time_uuid_spec.rb +17 -4
- data/spec/cql/uuid_spec.rb +5 -1
- data/spec/integration/protocol_spec.rb +48 -42
- data/spec/spec_helper.rb +0 -1
- metadata +27 -39
- data/lib/cql/byte_buffer.rb +0 -177
- data/lib/cql/client/synchronous_client.rb +0 -79
- data/lib/cql/client/synchronous_prepared_statement.rb +0 -63
- data/lib/cql/future.rb +0 -515
- data/lib/cql/io.rb +0 -15
- data/lib/cql/io/connection.rb +0 -220
- data/lib/cql/io/io_reactor.rb +0 -349
- data/lib/cql/protocol/decoding.rb +0 -187
- data/lib/cql/protocol/encoding.rb +0 -114
- data/spec/cql/byte_buffer_spec.rb +0 -337
- data/spec/cql/client/synchronous_client_spec.rb +0 -170
- data/spec/cql/client/synchronous_prepared_statement_spec.rb +0 -155
- data/spec/cql/future_spec.rb +0 -737
- data/spec/cql/io/connection_spec.rb +0 -484
- data/spec/cql/io/io_reactor_spec.rb +0 -402
- data/spec/cql/protocol/decoding_spec.rb +0 -547
- data/spec/cql/protocol/encoding_spec.rb +0 -386
- data/spec/integration/io_spec.rb +0 -283
- data/spec/support/fake_server.rb +0 -106
data/spec/support/fake_server.rb
DELETED
@@ -1,106 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
class FakeServer
|
4
|
-
attr_reader :port, :connects, :disconnects
|
5
|
-
|
6
|
-
def initialize(port=(2**15 + rand(2**15)))
|
7
|
-
@port = port
|
8
|
-
@state = {}
|
9
|
-
@lock = Mutex.new
|
10
|
-
@connects = 0
|
11
|
-
@disconnects = 0
|
12
|
-
@connections = []
|
13
|
-
@received_bytes = ''
|
14
|
-
end
|
15
|
-
|
16
|
-
def start!(options={})
|
17
|
-
@lock.synchronize do
|
18
|
-
return if @running
|
19
|
-
@running = true
|
20
|
-
end
|
21
|
-
@sockets = [TCPServer.new(@port)]
|
22
|
-
@started = Cql::Promise.new
|
23
|
-
@thread = Thread.start do
|
24
|
-
Thread.current.abort_on_exception = true
|
25
|
-
sleep(options[:accept_delay] || 0)
|
26
|
-
@started.fulfill
|
27
|
-
io_loop
|
28
|
-
end
|
29
|
-
@started.future.value
|
30
|
-
self
|
31
|
-
end
|
32
|
-
|
33
|
-
def stop!
|
34
|
-
@lock.synchronize do
|
35
|
-
return unless @running
|
36
|
-
@running = false
|
37
|
-
end
|
38
|
-
if defined? @started
|
39
|
-
@thread.join
|
40
|
-
@sockets.each(&:close)
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
def broadcast!(bytes)
|
45
|
-
@lock.synchronize do
|
46
|
-
@connections.each { |c| c.write_nonblock(bytes) }
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
def await_connects!(n=1)
|
51
|
-
started_at = Time.now
|
52
|
-
until @connects >= n
|
53
|
-
sleep(0.01)
|
54
|
-
raise 'Waited longer than 5s!' if (Time.now - started_at) > 5
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
def await_disconnects!(n=1)
|
59
|
-
started_at = Time.now
|
60
|
-
until @disconnects >= n
|
61
|
-
sleep(0.01)
|
62
|
-
raise 'Waited longer than 5s!' if (Time.now - started_at) > 5
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
def received_bytes
|
67
|
-
@lock.synchronize do
|
68
|
-
return @received_bytes.dup
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
private
|
73
|
-
|
74
|
-
def io_loop
|
75
|
-
while @running
|
76
|
-
acceptables, _ = IO.select(@sockets, @connections, nil, 0)
|
77
|
-
readables, writables, _ = IO.select(@connections, @connections, nil, 0)
|
78
|
-
|
79
|
-
if acceptables
|
80
|
-
acceptables.each do |socket|
|
81
|
-
connection, _ = socket.accept_nonblock
|
82
|
-
@lock.synchronize do
|
83
|
-
@connects += 1
|
84
|
-
@connections << connection
|
85
|
-
end
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
if readables
|
90
|
-
readables.each do |readable|
|
91
|
-
begin
|
92
|
-
bytes = readable.read_nonblock(2**16)
|
93
|
-
@lock.synchronize do
|
94
|
-
@received_bytes << bytes
|
95
|
-
end
|
96
|
-
rescue EOFError
|
97
|
-
@lock.synchronize do
|
98
|
-
@connections.delete(readable)
|
99
|
-
@disconnects += 1
|
100
|
-
end
|
101
|
-
end
|
102
|
-
end
|
103
|
-
end
|
104
|
-
end
|
105
|
-
end
|
106
|
-
end
|