cassandra-driver 0.1.0.alpha1 → 1.0.0.beta.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (106) hide show
  1. data/.yardopts +4 -0
  2. data/README.md +117 -0
  3. data/lib/cassandra.rb +320 -0
  4. data/lib/cassandra/auth.rb +97 -0
  5. data/lib/cassandra/auth/providers.rb +16 -0
  6. data/lib/cassandra/auth/providers/password.rb +73 -0
  7. data/lib/cassandra/client.rb +144 -0
  8. data/lib/cassandra/client/batch.rb +212 -0
  9. data/lib/cassandra/client/client.rb +591 -0
  10. data/lib/cassandra/client/column_metadata.rb +54 -0
  11. data/lib/cassandra/client/connection_manager.rb +72 -0
  12. data/lib/cassandra/client/connector.rb +272 -0
  13. data/lib/cassandra/client/execute_options_decoder.rb +59 -0
  14. data/lib/cassandra/client/null_logger.rb +37 -0
  15. data/lib/cassandra/client/peer_discovery.rb +50 -0
  16. data/lib/cassandra/client/prepared_statement.rb +314 -0
  17. data/lib/cassandra/client/query_result.rb +230 -0
  18. data/lib/cassandra/client/request_runner.rb +71 -0
  19. data/lib/cassandra/client/result_metadata.rb +48 -0
  20. data/lib/cassandra/client/void_result.rb +78 -0
  21. data/lib/cassandra/cluster.rb +191 -0
  22. data/lib/cassandra/cluster/client.rb +767 -0
  23. data/lib/cassandra/cluster/connector.rb +231 -0
  24. data/lib/cassandra/cluster/control_connection.rb +420 -0
  25. data/lib/cassandra/cluster/options.rb +40 -0
  26. data/lib/cassandra/cluster/registry.rb +181 -0
  27. data/lib/cassandra/cluster/schema.rb +321 -0
  28. data/lib/cassandra/cluster/schema/type_parser.rb +138 -0
  29. data/lib/cassandra/column.rb +92 -0
  30. data/lib/cassandra/compression.rb +66 -0
  31. data/lib/cassandra/compression/compressors/lz4.rb +72 -0
  32. data/lib/cassandra/compression/compressors/snappy.rb +66 -0
  33. data/lib/cassandra/driver.rb +86 -0
  34. data/lib/cassandra/errors.rb +79 -0
  35. data/lib/cassandra/execution/info.rb +51 -0
  36. data/lib/cassandra/execution/options.rb +77 -0
  37. data/lib/cassandra/execution/trace.rb +152 -0
  38. data/lib/cassandra/future.rb +675 -0
  39. data/lib/cassandra/host.rb +75 -0
  40. data/lib/cassandra/keyspace.rb +120 -0
  41. data/lib/cassandra/listener.rb +87 -0
  42. data/lib/cassandra/load_balancing.rb +112 -0
  43. data/lib/cassandra/load_balancing/policies.rb +18 -0
  44. data/lib/cassandra/load_balancing/policies/dc_aware_round_robin.rb +149 -0
  45. data/lib/cassandra/load_balancing/policies/round_robin.rb +95 -0
  46. data/lib/cassandra/load_balancing/policies/white_list.rb +90 -0
  47. data/lib/cassandra/protocol.rb +93 -0
  48. data/lib/cassandra/protocol/cql_byte_buffer.rb +307 -0
  49. data/lib/cassandra/protocol/cql_protocol_handler.rb +323 -0
  50. data/lib/cassandra/protocol/frame_decoder.rb +128 -0
  51. data/lib/cassandra/protocol/frame_encoder.rb +48 -0
  52. data/lib/cassandra/protocol/request.rb +38 -0
  53. data/lib/cassandra/protocol/requests/auth_response_request.rb +47 -0
  54. data/lib/cassandra/protocol/requests/batch_request.rb +76 -0
  55. data/lib/cassandra/protocol/requests/credentials_request.rb +47 -0
  56. data/lib/cassandra/protocol/requests/execute_request.rb +103 -0
  57. data/lib/cassandra/protocol/requests/options_request.rb +39 -0
  58. data/lib/cassandra/protocol/requests/prepare_request.rb +50 -0
  59. data/lib/cassandra/protocol/requests/query_request.rb +153 -0
  60. data/lib/cassandra/protocol/requests/register_request.rb +38 -0
  61. data/lib/cassandra/protocol/requests/startup_request.rb +49 -0
  62. data/lib/cassandra/protocol/requests/void_query_request.rb +24 -0
  63. data/lib/cassandra/protocol/response.rb +38 -0
  64. data/lib/cassandra/protocol/responses/auth_challenge_response.rb +41 -0
  65. data/lib/cassandra/protocol/responses/auth_success_response.rb +41 -0
  66. data/lib/cassandra/protocol/responses/authenticate_response.rb +41 -0
  67. data/lib/cassandra/protocol/responses/detailed_error_response.rb +60 -0
  68. data/lib/cassandra/protocol/responses/error_response.rb +50 -0
  69. data/lib/cassandra/protocol/responses/event_response.rb +39 -0
  70. data/lib/cassandra/protocol/responses/prepared_result_response.rb +64 -0
  71. data/lib/cassandra/protocol/responses/raw_rows_result_response.rb +43 -0
  72. data/lib/cassandra/protocol/responses/ready_response.rb +44 -0
  73. data/lib/cassandra/protocol/responses/result_response.rb +48 -0
  74. data/lib/cassandra/protocol/responses/rows_result_response.rb +139 -0
  75. data/lib/cassandra/protocol/responses/schema_change_event_response.rb +60 -0
  76. data/lib/cassandra/protocol/responses/schema_change_result_response.rb +57 -0
  77. data/lib/cassandra/protocol/responses/set_keyspace_result_response.rb +42 -0
  78. data/lib/cassandra/protocol/responses/status_change_event_response.rb +44 -0
  79. data/lib/cassandra/protocol/responses/supported_response.rb +41 -0
  80. data/lib/cassandra/protocol/responses/topology_change_event_response.rb +34 -0
  81. data/lib/cassandra/protocol/responses/void_result_response.rb +39 -0
  82. data/lib/cassandra/protocol/type_converter.rb +384 -0
  83. data/lib/cassandra/reconnection.rb +49 -0
  84. data/lib/cassandra/reconnection/policies.rb +20 -0
  85. data/lib/cassandra/reconnection/policies/constant.rb +48 -0
  86. data/lib/cassandra/reconnection/policies/exponential.rb +79 -0
  87. data/lib/cassandra/result.rb +215 -0
  88. data/lib/cassandra/retry.rb +142 -0
  89. data/lib/cassandra/retry/policies.rb +21 -0
  90. data/lib/cassandra/retry/policies/default.rb +47 -0
  91. data/lib/cassandra/retry/policies/downgrading_consistency.rb +71 -0
  92. data/lib/cassandra/retry/policies/fallthrough.rb +39 -0
  93. data/lib/cassandra/session.rb +195 -0
  94. data/lib/cassandra/statement.rb +22 -0
  95. data/lib/cassandra/statements.rb +23 -0
  96. data/lib/cassandra/statements/batch.rb +95 -0
  97. data/lib/cassandra/statements/bound.rb +46 -0
  98. data/lib/cassandra/statements/prepared.rb +59 -0
  99. data/lib/cassandra/statements/simple.rb +58 -0
  100. data/lib/cassandra/statements/void.rb +33 -0
  101. data/lib/cassandra/table.rb +254 -0
  102. data/lib/cassandra/time_uuid.rb +141 -0
  103. data/lib/cassandra/util.rb +169 -0
  104. data/lib/cassandra/uuid.rb +104 -0
  105. data/lib/cassandra/version.rb +17 -1
  106. metadata +134 -8
@@ -0,0 +1,153 @@
1
+ # encoding: utf-8
2
+
3
+ #--
4
+ # Copyright 2013-2014 DataStax, Inc.
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #++
18
+
19
+ module Cassandra
20
+ module Protocol
21
+ class QueryRequest < Request
22
+ attr_reader :cql, :values, :type_hints, :serial_consistency, :page_size, :paging_state
23
+ attr_accessor :consistency, :retries
24
+
25
+ def initialize(cql, values, type_hints, consistency, serial_consistency=nil, page_size=nil, paging_state=nil, trace=false)
26
+ raise ArgumentError, %(No CQL given!) unless cql
27
+ raise ArgumentError, %(No such consistency: #{consistency.inspect}) if consistency.nil? || !CONSISTENCIES.include?(consistency)
28
+ raise ArgumentError, %(No such consistency: #{serial_consistency.inspect}) unless serial_consistency.nil? || CONSISTENCIES.include?(serial_consistency)
29
+ raise ArgumentError, %(Bound values and type hints must have the same number of elements (got #{values.size} values and #{type_hints.size} hints)) if values && type_hints && values.size != type_hints.size
30
+ raise ArgumentError, %(Paging state given but no page size) if paging_state && !page_size
31
+ super(7, trace)
32
+ @cql = cql
33
+ @values = values || EMPTY_LIST
34
+ @type_hints = type_hints || EMPTY_LIST
35
+ @consistency = consistency
36
+ @serial_consistency = serial_consistency
37
+ @page_size = page_size
38
+ @paging_state = paging_state
39
+ end
40
+
41
+ def write(protocol_version, buffer)
42
+ if protocol_version > 1
43
+ buffer.append_long_string(@cql)
44
+ else
45
+ buffer.append_long_string(serialized_cql)
46
+ end
47
+ buffer.append_consistency(@consistency)
48
+ if protocol_version > 1
49
+ flags = 0
50
+ flags |= 0x04 if @page_size
51
+ flags |= 0x08 if @paging_state
52
+ flags |= 0x10 if @serial_consistency
53
+ if @values && @values.size > 0
54
+ flags |= 0x01
55
+ buffer.append(flags.chr)
56
+ self.class.encode_values(buffer, @values, @type_hints)
57
+ else
58
+ buffer.append(flags.chr)
59
+ end
60
+ buffer.append_int(@page_size) if @page_size
61
+ buffer.append_bytes(@paging_state) if @paging_state
62
+ buffer.append_consistency(@serial_consistency) if @serial_consistency
63
+ end
64
+ buffer
65
+ end
66
+
67
+ def to_s
68
+ %(QUERY "#@cql" #{@consistency.to_s.upcase})
69
+ end
70
+
71
+ def eql?(rq)
72
+ self.class === rq &&
73
+ rq.cql == self.cql &&
74
+ rq.values == self.values &&
75
+ rq.type_hints == self.type_hints &&
76
+ rq.consistency == self.consistency &&
77
+ rq.serial_consistency == self.serial_consistency &&
78
+ rq.page_size == self.page_size &&
79
+ rq.paging_state == self.paging_state
80
+ end
81
+ alias_method :==, :eql?
82
+
83
+ def hash
84
+ h = 0xcbf29ce484222325
85
+ h = 0xffffffffffffffff & (0x100000001b3 * (h ^ @cql.hash))
86
+ h = 0xffffffffffffffff & (0x100000001b3 * (h ^ @values.hash))
87
+ h = 0xffffffffffffffff & (0x100000001b3 * (h ^ @type_hints.hash))
88
+ h = 0xffffffffffffffff & (0x100000001b3 * (h ^ @consistency.hash))
89
+ h = 0xffffffffffffffff & (0x100000001b3 * (h ^ @serial_consistency.hash))
90
+ h = 0xffffffffffffffff & (0x100000001b3 * (h ^ @page_size.hash))
91
+ h = 0xffffffffffffffff & (0x100000001b3 * (h ^ @paging_state.hash))
92
+ h
93
+ end
94
+
95
+ def self.encode_values(buffer, values, hints)
96
+ if values && values.size > 0
97
+ buffer.append_short(values.size)
98
+ values.each_with_index do |value, index|
99
+ type = (hints && hints[index]) || guess_type(value)
100
+ raise EncodingError, "Could not guess a suitable type for #{value.inspect}" unless type
101
+ TYPE_CONVERTER.to_bytes(buffer, type, value)
102
+ end
103
+ buffer
104
+ else
105
+ buffer.append_short(0)
106
+ end
107
+ end
108
+
109
+ private
110
+
111
+ def serialized_cql
112
+ return @cql if @values.nil? || @values.empty?
113
+ i = -1
114
+ @cql.gsub('?') { Util.encode(@values[i += 1]) }
115
+ end
116
+
117
+ def self.guess_type(value)
118
+ type = TYPE_GUESSES[value.class]
119
+ if type == :map
120
+ pair = value.first
121
+ [type, guess_type(pair[0]), guess_type(pair[1])]
122
+ elsif type == :list
123
+ [type, guess_type(value.first)]
124
+ elsif type == :set
125
+ [type, guess_type(value.first)]
126
+ else
127
+ type
128
+ end
129
+ end
130
+
131
+ TYPE_GUESSES = {
132
+ String => :varchar,
133
+ Fixnum => :bigint,
134
+ Float => :double,
135
+ Bignum => :varint,
136
+ BigDecimal => :decimal,
137
+ TrueClass => :boolean,
138
+ FalseClass => :boolean,
139
+ NilClass => :bigint,
140
+ Uuid => :uuid,
141
+ TimeUuid => :uuid,
142
+ IPAddr => :inet,
143
+ Time => :timestamp,
144
+ Hash => :map,
145
+ Array => :list,
146
+ Set => :set,
147
+ }.freeze
148
+ TYPE_CONVERTER = TypeConverter.new
149
+ EMPTY_LIST = [].freeze
150
+ NO_FLAGS = "\x00".freeze
151
+ end
152
+ end
153
+ end
@@ -0,0 +1,38 @@
1
+ # encoding: utf-8
2
+
3
+ #--
4
+ # Copyright 2013-2014 DataStax, Inc.
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #++
18
+
19
+ module Cassandra
20
+ module Protocol
21
+ class RegisterRequest < Request
22
+ attr_reader :events
23
+
24
+ def initialize(*events)
25
+ super(11)
26
+ @events = events
27
+ end
28
+
29
+ def write(protocol_version, buffer)
30
+ buffer.append_string_list(@events)
31
+ end
32
+
33
+ def to_s
34
+ %(REGISTER #@events)
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,49 @@
1
+ # encoding: utf-8
2
+
3
+ #--
4
+ # Copyright 2013-2014 DataStax, Inc.
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #++
18
+
19
+ module Cassandra
20
+ module Protocol
21
+ class StartupRequest < Request
22
+ attr_reader :options
23
+
24
+ def initialize(cql_version, compression=nil)
25
+ super(1)
26
+ raise ArgumentError, "Invalid CQL version: #{cql_version.inspect}" unless cql_version
27
+ @options = {CQL_VERSION => cql_version}
28
+ @options[COMPRESSION] = compression if compression
29
+ end
30
+
31
+ def compressable?
32
+ false
33
+ end
34
+
35
+ def write(protocol_version, buffer)
36
+ buffer.append_string_map(@options)
37
+ end
38
+
39
+ def to_s
40
+ %(STARTUP #@options)
41
+ end
42
+
43
+ private
44
+
45
+ CQL_VERSION = 'CQL_VERSION'.freeze
46
+ COMPRESSION = 'COMPRESSION'.freeze
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,24 @@
1
+ # encoding: utf-8
2
+
3
+ #--
4
+ # Copyright 2013-2014 DataStax, Inc.
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #++
18
+
19
+ module Cassandra
20
+ module Protocol
21
+ class VoidQueryRequest
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,38 @@
1
+ # encoding: utf-8
2
+
3
+ #--
4
+ # Copyright 2013-2014 DataStax, Inc.
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #++
18
+
19
+ module Cassandra
20
+ module Protocol
21
+ class Response
22
+ def self.decode(opcode, protocol_version, buffer, length, trace_id)
23
+ response_class = RESPONSE_TYPES[opcode]
24
+ if response_class
25
+ response_class.decode(protocol_version, buffer, length, trace_id)
26
+ else
27
+ raise UnsupportedOperationError, "The operation #{opcode} is not supported"
28
+ end
29
+ end
30
+
31
+ private
32
+
33
+ RESPONSE_TYPES = [
34
+ # populated by subclasses
35
+ ]
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,41 @@
1
+ # encoding: utf-8
2
+
3
+ #--
4
+ # Copyright 2013-2014 DataStax, Inc.
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #++
18
+
19
+ module Cassandra
20
+ module Protocol
21
+ class AuthChallengeResponse < Response
22
+ attr_reader :token
23
+
24
+ def self.decode(protocol_version, buffer, length, trace_id=nil)
25
+ new(buffer.read_bytes)
26
+ end
27
+
28
+ def initialize(token)
29
+ @token = token
30
+ end
31
+
32
+ def to_s
33
+ %(AUTH_CHALLENGE #{@token.bytesize})
34
+ end
35
+
36
+ private
37
+
38
+ RESPONSE_TYPES[0x0e] = self
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,41 @@
1
+ # encoding: utf-8
2
+
3
+ #--
4
+ # Copyright 2013-2014 DataStax, Inc.
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #++
18
+
19
+ module Cassandra
20
+ module Protocol
21
+ class AuthSuccessResponse < Response
22
+ attr_reader :token
23
+
24
+ def self.decode(protocol_version, buffer, length, trace_id=nil)
25
+ new(buffer.read_bytes)
26
+ end
27
+
28
+ def initialize(token)
29
+ @token = token
30
+ end
31
+
32
+ def to_s
33
+ %(AUTH_SUCCESS #{@token.bytesize})
34
+ end
35
+
36
+ private
37
+
38
+ RESPONSE_TYPES[0x10] = self
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,41 @@
1
+ # encoding: utf-8
2
+
3
+ #--
4
+ # Copyright 2013-2014 DataStax, Inc.
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #++
18
+
19
+ module Cassandra
20
+ module Protocol
21
+ class AuthenticateResponse < Response
22
+ attr_reader :authentication_class
23
+
24
+ def self.decode(protocol_version, buffer, length, trace_id=nil)
25
+ new(buffer.read_string)
26
+ end
27
+
28
+ def initialize(authentication_class)
29
+ @authentication_class = authentication_class
30
+ end
31
+
32
+ def to_s
33
+ %(AUTHENTICATE #{authentication_class})
34
+ end
35
+
36
+ private
37
+
38
+ RESPONSE_TYPES[0x03] = self
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,60 @@
1
+ # encoding: utf-8
2
+
3
+ #--
4
+ # Copyright 2013-2014 DataStax, Inc.
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #++
18
+
19
+ module Cassandra
20
+ module Protocol
21
+ class DetailedErrorResponse < ErrorResponse
22
+ attr_reader :details
23
+
24
+ def initialize(code, message, details)
25
+ super(code, message)
26
+ @details = details
27
+ end
28
+
29
+ def self.decode(code, message, protocol_version, buffer, length, trace_id=nil)
30
+ details = {}
31
+ case code
32
+ when 0x1000 # unavailable
33
+ details[:cl] = buffer.read_consistency
34
+ details[:required] = buffer.read_int
35
+ details[:alive] = buffer.read_int
36
+ when 0x1100 # write_timeout
37
+ details[:cl] = buffer.read_consistency
38
+ details[:received] = buffer.read_int
39
+ details[:blockfor] = buffer.read_int
40
+ details[:write_type] = buffer.read_string
41
+ when 0x1200 # read_timeout
42
+ details[:cl] = buffer.read_consistency
43
+ details[:received] = buffer.read_int
44
+ details[:blockfor] = buffer.read_int
45
+ details[:data_present] = buffer.read_byte != 0
46
+ when 0x2400 # already_exists
47
+ details[:ks] = buffer.read_string
48
+ details[:table] = buffer.read_string
49
+ when 0x2500
50
+ details[:id] = buffer.read_short_bytes
51
+ end
52
+ new(code, message, details)
53
+ end
54
+
55
+ def to_s
56
+ "#{super} #{@details}"
57
+ end
58
+ end
59
+ end
60
+ end