yugabyte-ycql-driver 3.2.3.1

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 (145) hide show
  1. checksums.yaml +7 -0
  2. data/.yardopts +13 -0
  3. data/README.md +242 -0
  4. data/ext/cassandra_murmur3/cassandra_murmur3.c +178 -0
  5. data/ext/cassandra_murmur3/extconf.rb +2 -0
  6. data/lib/cassandra/address_resolution.rb +36 -0
  7. data/lib/cassandra/address_resolution/policies.rb +2 -0
  8. data/lib/cassandra/address_resolution/policies/ec2_multi_region.rb +56 -0
  9. data/lib/cassandra/address_resolution/policies/none.rb +35 -0
  10. data/lib/cassandra/aggregate.rb +123 -0
  11. data/lib/cassandra/argument.rb +51 -0
  12. data/lib/cassandra/attr_boolean.rb +33 -0
  13. data/lib/cassandra/auth.rb +100 -0
  14. data/lib/cassandra/auth/providers.rb +17 -0
  15. data/lib/cassandra/auth/providers/password.rb +65 -0
  16. data/lib/cassandra/cassandra_logger.rb +80 -0
  17. data/lib/cassandra/cluster.rb +331 -0
  18. data/lib/cassandra/cluster/client.rb +1612 -0
  19. data/lib/cassandra/cluster/connection_pool.rb +78 -0
  20. data/lib/cassandra/cluster/connector.rb +372 -0
  21. data/lib/cassandra/cluster/control_connection.rb +962 -0
  22. data/lib/cassandra/cluster/failed_connection.rb +35 -0
  23. data/lib/cassandra/cluster/metadata.rb +142 -0
  24. data/lib/cassandra/cluster/options.rb +145 -0
  25. data/lib/cassandra/cluster/registry.rb +284 -0
  26. data/lib/cassandra/cluster/schema.rb +405 -0
  27. data/lib/cassandra/cluster/schema/cql_type_parser.rb +112 -0
  28. data/lib/cassandra/cluster/schema/fetchers.rb +1627 -0
  29. data/lib/cassandra/cluster/schema/fqcn_type_parser.rb +175 -0
  30. data/lib/cassandra/cluster/schema/partitioners.rb +21 -0
  31. data/lib/cassandra/cluster/schema/partitioners/murmur3.rb +45 -0
  32. data/lib/cassandra/cluster/schema/partitioners/ordered.rb +37 -0
  33. data/lib/cassandra/cluster/schema/partitioners/random.rb +37 -0
  34. data/lib/cassandra/cluster/schema/replication_strategies.rb +21 -0
  35. data/lib/cassandra/cluster/schema/replication_strategies/network_topology.rb +102 -0
  36. data/lib/cassandra/cluster/schema/replication_strategies/none.rb +39 -0
  37. data/lib/cassandra/cluster/schema/replication_strategies/simple.rb +44 -0
  38. data/lib/cassandra/column.rb +66 -0
  39. data/lib/cassandra/column_container.rb +326 -0
  40. data/lib/cassandra/compression.rb +69 -0
  41. data/lib/cassandra/compression/compressors/lz4.rb +73 -0
  42. data/lib/cassandra/compression/compressors/snappy.rb +69 -0
  43. data/lib/cassandra/custom_data.rb +53 -0
  44. data/lib/cassandra/driver.rb +260 -0
  45. data/lib/cassandra/errors.rb +784 -0
  46. data/lib/cassandra/execution/info.rb +69 -0
  47. data/lib/cassandra/execution/options.rb +267 -0
  48. data/lib/cassandra/execution/profile.rb +153 -0
  49. data/lib/cassandra/execution/profile_manager.rb +71 -0
  50. data/lib/cassandra/execution/trace.rb +192 -0
  51. data/lib/cassandra/executors.rb +113 -0
  52. data/lib/cassandra/function.rb +156 -0
  53. data/lib/cassandra/function_collection.rb +85 -0
  54. data/lib/cassandra/future.rb +794 -0
  55. data/lib/cassandra/host.rb +102 -0
  56. data/lib/cassandra/index.rb +118 -0
  57. data/lib/cassandra/keyspace.rb +473 -0
  58. data/lib/cassandra/listener.rb +87 -0
  59. data/lib/cassandra/load_balancing.rb +121 -0
  60. data/lib/cassandra/load_balancing/policies.rb +20 -0
  61. data/lib/cassandra/load_balancing/policies/dc_aware_round_robin.rb +172 -0
  62. data/lib/cassandra/load_balancing/policies/round_robin.rb +141 -0
  63. data/lib/cassandra/load_balancing/policies/token_aware.rb +149 -0
  64. data/lib/cassandra/load_balancing/policies/white_list.rb +100 -0
  65. data/lib/cassandra/materialized_view.rb +92 -0
  66. data/lib/cassandra/null_logger.rb +56 -0
  67. data/lib/cassandra/protocol.rb +102 -0
  68. data/lib/cassandra/protocol/coder.rb +1085 -0
  69. data/lib/cassandra/protocol/cql_byte_buffer.rb +418 -0
  70. data/lib/cassandra/protocol/cql_protocol_handler.rb +448 -0
  71. data/lib/cassandra/protocol/request.rb +41 -0
  72. data/lib/cassandra/protocol/requests/auth_response_request.rb +51 -0
  73. data/lib/cassandra/protocol/requests/batch_request.rb +117 -0
  74. data/lib/cassandra/protocol/requests/credentials_request.rb +51 -0
  75. data/lib/cassandra/protocol/requests/execute_request.rb +122 -0
  76. data/lib/cassandra/protocol/requests/options_request.rb +39 -0
  77. data/lib/cassandra/protocol/requests/prepare_request.rb +59 -0
  78. data/lib/cassandra/protocol/requests/query_request.rb +112 -0
  79. data/lib/cassandra/protocol/requests/register_request.rb +38 -0
  80. data/lib/cassandra/protocol/requests/startup_request.rb +49 -0
  81. data/lib/cassandra/protocol/requests/void_query_request.rb +24 -0
  82. data/lib/cassandra/protocol/response.rb +28 -0
  83. data/lib/cassandra/protocol/responses/already_exists_error_response.rb +50 -0
  84. data/lib/cassandra/protocol/responses/auth_challenge_response.rb +36 -0
  85. data/lib/cassandra/protocol/responses/auth_success_response.rb +36 -0
  86. data/lib/cassandra/protocol/responses/authenticate_response.rb +36 -0
  87. data/lib/cassandra/protocol/responses/error_response.rb +142 -0
  88. data/lib/cassandra/protocol/responses/event_response.rb +30 -0
  89. data/lib/cassandra/protocol/responses/function_failure_error_response.rb +52 -0
  90. data/lib/cassandra/protocol/responses/prepared_result_response.rb +62 -0
  91. data/lib/cassandra/protocol/responses/raw_rows_result_response.rb +59 -0
  92. data/lib/cassandra/protocol/responses/read_failure_error_response.rb +71 -0
  93. data/lib/cassandra/protocol/responses/read_timeout_error_response.rb +61 -0
  94. data/lib/cassandra/protocol/responses/ready_response.rb +43 -0
  95. data/lib/cassandra/protocol/responses/result_response.rb +42 -0
  96. data/lib/cassandra/protocol/responses/rows_result_response.rb +39 -0
  97. data/lib/cassandra/protocol/responses/schema_change_event_response.rb +73 -0
  98. data/lib/cassandra/protocol/responses/schema_change_result_response.rb +70 -0
  99. data/lib/cassandra/protocol/responses/set_keyspace_result_response.rb +37 -0
  100. data/lib/cassandra/protocol/responses/status_change_event_response.rb +39 -0
  101. data/lib/cassandra/protocol/responses/supported_response.rb +36 -0
  102. data/lib/cassandra/protocol/responses/topology_change_event_response.rb +33 -0
  103. data/lib/cassandra/protocol/responses/unavailable_error_response.rb +58 -0
  104. data/lib/cassandra/protocol/responses/unprepared_error_response.rb +48 -0
  105. data/lib/cassandra/protocol/responses/void_result_response.rb +34 -0
  106. data/lib/cassandra/protocol/responses/write_failure_error_response.rb +73 -0
  107. data/lib/cassandra/protocol/responses/write_timeout_error_response.rb +63 -0
  108. data/lib/cassandra/protocol/v1.rb +326 -0
  109. data/lib/cassandra/protocol/v3.rb +358 -0
  110. data/lib/cassandra/protocol/v4.rb +478 -0
  111. data/lib/cassandra/reconnection.rb +49 -0
  112. data/lib/cassandra/reconnection/policies.rb +20 -0
  113. data/lib/cassandra/reconnection/policies/constant.rb +46 -0
  114. data/lib/cassandra/reconnection/policies/exponential.rb +79 -0
  115. data/lib/cassandra/result.rb +276 -0
  116. data/lib/cassandra/retry.rb +154 -0
  117. data/lib/cassandra/retry/policies.rb +21 -0
  118. data/lib/cassandra/retry/policies/default.rb +53 -0
  119. data/lib/cassandra/retry/policies/downgrading_consistency.rb +73 -0
  120. data/lib/cassandra/retry/policies/fallthrough.rb +39 -0
  121. data/lib/cassandra/session.rb +270 -0
  122. data/lib/cassandra/statement.rb +32 -0
  123. data/lib/cassandra/statements.rb +23 -0
  124. data/lib/cassandra/statements/batch.rb +146 -0
  125. data/lib/cassandra/statements/bound.rb +65 -0
  126. data/lib/cassandra/statements/prepared.rb +235 -0
  127. data/lib/cassandra/statements/simple.rb +118 -0
  128. data/lib/cassandra/statements/void.rb +38 -0
  129. data/lib/cassandra/table.rb +240 -0
  130. data/lib/cassandra/time.rb +103 -0
  131. data/lib/cassandra/time_uuid.rb +78 -0
  132. data/lib/cassandra/timestamp_generator.rb +37 -0
  133. data/lib/cassandra/timestamp_generator/simple.rb +38 -0
  134. data/lib/cassandra/timestamp_generator/ticking_on_duplicate.rb +58 -0
  135. data/lib/cassandra/trigger.rb +67 -0
  136. data/lib/cassandra/tuple.rb +131 -0
  137. data/lib/cassandra/types.rb +1704 -0
  138. data/lib/cassandra/udt.rb +443 -0
  139. data/lib/cassandra/util.rb +464 -0
  140. data/lib/cassandra/uuid.rb +110 -0
  141. data/lib/cassandra/uuid/generator.rb +212 -0
  142. data/lib/cassandra/version.rb +21 -0
  143. data/lib/datastax/cassandra.rb +47 -0
  144. data/lib/ycql.rb +842 -0
  145. metadata +243 -0
@@ -0,0 +1,149 @@
1
+ # encoding: utf-8
2
+
3
+ #--
4
+ # Copyright 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 LoadBalancing
21
+ module Policies
22
+ class TokenAware < Policy
23
+ # @private
24
+ class Plan
25
+ def initialize(hosts, policy, keyspace, statement, options)
26
+ @hosts = hosts
27
+ @policy = policy
28
+ @keyspace = keyspace
29
+ @statement = statement
30
+ @options = options
31
+ @seen = ::Hash.new
32
+ end
33
+
34
+ def has_next?
35
+ until @hosts.empty?
36
+ host = @hosts.shift
37
+
38
+ next unless @policy.distance(host) == :local
39
+ @seen[host] = true
40
+ @next = host
41
+ break
42
+ end
43
+
44
+ return true if @next
45
+
46
+ @plan ||= @policy.plan(@keyspace, @statement, @options)
47
+
48
+ while @plan.has_next?
49
+ host = @plan.next
50
+
51
+ unless @seen[host]
52
+ @next = host
53
+ return true
54
+ end
55
+ end
56
+
57
+ false
58
+ end
59
+
60
+ def next
61
+ host = @next
62
+ @next = nil
63
+ host
64
+ end
65
+ end
66
+
67
+ extend Forwardable
68
+
69
+ # @!method distance(host)
70
+ # Delegates to wrapped policy
71
+ # @see Cassandra::LoadBalancing::Policy#distance
72
+ #
73
+ # @!method host_found(host)
74
+ # Delegates to wrapped policy
75
+ # @see Cassandra::LoadBalancing::Policy#host_found
76
+ #
77
+ # @!method host_up(host)
78
+ # Delegates to wrapped policy
79
+ # @see Cassandra::LoadBalancing::Policy#host_up
80
+ #
81
+ # @!method host_down(host)
82
+ # Delegates to wrapped policy
83
+ # @see Cassandra::LoadBalancing::Policy#host_down
84
+ #
85
+ # @!method host_lost(host)
86
+ # Delegates to wrapped policy
87
+ # @see Cassandra::LoadBalancing::Policy#host_lost
88
+ def_delegators :@policy, :distance, :host_found, :host_up, :host_down, :host_lost
89
+
90
+ # @param wrapped_policy [Cassandra::LoadBalancing::Policy] actual
91
+ # policy to filter
92
+ # @param shuffle [Boolean] (true) whether or not to shuffle the replicas
93
+ #
94
+ # @note If replicas are not shuffled (`shuffle = false`), then it is
95
+ # possibile to create hotspots in a write-heavy scenario, where most
96
+ # of the write requests will be handled by the same node(s). The
97
+ # default behavior of shuffling replicas helps mitigate this by
98
+ # universally distributing write load between replicas. However, it
99
+ # under-utilizes read caching and forces multiple replicas to cache
100
+ # the same read statements.
101
+ def initialize(wrapped_policy, shuffle = true)
102
+ methods = [:host_up, :host_down, :host_found, :host_lost, :setup, :teardown,
103
+ :distance, :plan]
104
+
105
+ Util.assert_responds_to_all(methods, wrapped_policy) do
106
+ "supplied policy must respond to #{methods.inspect}, but doesn't"
107
+ end
108
+
109
+ @policy = wrapped_policy
110
+ @shuffle = !!shuffle
111
+ end
112
+
113
+ def setup(cluster)
114
+ @cluster = cluster
115
+ @policy.setup(cluster)
116
+ nil
117
+ end
118
+
119
+ def teardown(cluster)
120
+ @cluster = nil
121
+ @policy.teardown(cluster)
122
+ nil
123
+ end
124
+
125
+ def plan(keyspace, statement, options)
126
+ return @policy.plan(keyspace, statement, options) unless @cluster
127
+
128
+ replicas = @cluster.find_replicas(keyspace, statement)
129
+ return @policy.plan(keyspace, statement, options) if replicas.empty?
130
+
131
+ replicas = if @shuffle
132
+ replicas.shuffle
133
+ else
134
+ replicas.dup
135
+ end
136
+
137
+ Plan.new(replicas, @policy, keyspace, statement, options)
138
+ end
139
+
140
+ # @private
141
+ def inspect
142
+ "#<#{self.class.name}:0x#{object_id.to_s(16)} " \
143
+ "policy=#{@policy.inspect}, " \
144
+ "shuffle=#{@shuffle.inspect}>"
145
+ end
146
+ end
147
+ end
148
+ end
149
+ end
@@ -0,0 +1,100 @@
1
+ # encoding: utf-8
2
+
3
+ #--
4
+ # Copyright 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 LoadBalancing
21
+ module Policies
22
+ class WhiteList < Policy
23
+ extend Forwardable
24
+
25
+ # @!method plan(keyspace, statement, options)
26
+ # Delegates to wrapped policy
27
+ # @see Cassandra::LoadBalancing::Policy#plan
28
+ #
29
+ # @!method distance(host)
30
+ # Delegates to wrapped policy
31
+ # @see Cassandra::LoadBalancing::Policy#distance
32
+ def_delegators :@policy, :plan, :distance
33
+
34
+ # @param ips [Enumerable<String, IPAddr>] a list of ips to whitelist
35
+ # @param wrapped_policy [Cassandra::LoadBalancing::Policy] actual policy to filter
36
+ # @raise [ArgumentError] if arguments are of unexpected types
37
+ def initialize(ips, wrapped_policy)
38
+ Util.assert_instance_of(::Enumerable, ips) do
39
+ "ips must be an Enumerable, #{ips.inspect} given"
40
+ end
41
+ methods = [:host_up, :host_down, :host_found, :host_lost, :setup, :teardown,
42
+ :distance, :plan]
43
+ Util.assert_responds_to_all(methods, wrapped_policy) do
44
+ "supplied policy must respond to #{methods.inspect}, but doesn't"
45
+ end
46
+
47
+ @ips = ::Set.new
48
+ @policy = wrapped_policy
49
+
50
+ ips.each do |ip|
51
+ case ip
52
+ when ::IPAddr
53
+ @ips << ip
54
+ when ::String
55
+ @ips << ::IPAddr.new(ip)
56
+ else
57
+ raise ::ArgumentError, 'each ip must be a String or IPAddr, ' \
58
+ "#{ip.inspect} given"
59
+ end
60
+ end
61
+ end
62
+
63
+ # Delegates to wrapped policy if host's ip is whitelisted
64
+ # @param host [Cassandra::Host] a host instance
65
+ # @see Cassandra::LoadBalancing::Policy#host_found
66
+ def host_found(host)
67
+ @policy.host_found(host) if @ips.include?(host.ip)
68
+ end
69
+
70
+ # Delegates to wrapped policy if host's ip is whitelisted
71
+ # @param host [Cassandra::Host] a host instance
72
+ # @see Cassandra::LoadBalancing::Policy#host_lost
73
+ def host_lost(host)
74
+ @policy.host_lost(host) if @ips.include?(host.ip)
75
+ end
76
+
77
+ # Delegates to wrapped policy if host's ip is whitelisted
78
+ # @param host [Cassandra::Host] a host instance
79
+ # @see Cassandra::LoadBalancing::Policy#host_up
80
+ def host_up(host)
81
+ @policy.host_up(host) if @ips.include?(host.ip)
82
+ end
83
+
84
+ # Delegates to wrapped policy if host's ip is whitelisted
85
+ # @param host [Cassandra::Host] a host instance
86
+ # @see Cassandra::LoadBalancing::Policy#host_down
87
+ def host_down(host)
88
+ @policy.host_down(host) if @ips.include?(host.ip)
89
+ end
90
+
91
+ # @private
92
+ def inspect
93
+ "#<#{self.class.name}:0x#{object_id.to_s(16)} " \
94
+ "policy=#{@policy.inspect}, " \
95
+ "ips=#{@ips.inspect}>"
96
+ end
97
+ end
98
+ end
99
+ end
100
+ end
@@ -0,0 +1,92 @@
1
+ # encoding: utf-8
2
+
3
+ #--
4
+ # Copyright 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
+ # Represents a cassandra materialized view
21
+ # @see Cassandra::Keyspace#each_materialized_view
22
+ # @see Cassandra::Keyspace#materialized_view
23
+ class MaterializedView < ColumnContainer
24
+ # @private
25
+ def initialize(keyspace,
26
+ name,
27
+ partition_key,
28
+ clustering_columns,
29
+ other_columns,
30
+ options,
31
+ include_all_columns,
32
+ where_clause,
33
+ base_table_name,
34
+ id)
35
+ super(keyspace, name, partition_key, clustering_columns, other_columns, options, id)
36
+ @include_all_columns = include_all_columns
37
+ @where_clause = where_clause
38
+ @base_table_name = base_table_name
39
+ end
40
+
41
+ # @return [Table] the table that this materialized view applies to.
42
+ def base_table
43
+ @keyspace.table(@base_table_name)
44
+ end
45
+
46
+ # @return [String] a cql representation of this materialized view
47
+ def to_cql
48
+ keyspace_name = Util.escape_name(@keyspace.name)
49
+ cql = "CREATE MATERIALIZED VIEW #{keyspace_name}.#{Util.escape_name(@name)} AS\nSELECT "
50
+ cql << if @include_all_columns
51
+ '*'
52
+ else
53
+ @columns.map do |column|
54
+ Util.escape_name(column.name)
55
+ end.join(', ')
56
+ end
57
+ cql << "\nFROM #{keyspace_name}.#{Util.escape_name(@base_table_name)}"
58
+ cql << "\nWHERE #{@where_clause}" if @where_clause
59
+ cql << "\nPRIMARY KEY (("
60
+ cql << @partition_key.map do |column|
61
+ Util.escape_name(column.name)
62
+ end.join(', ')
63
+ cql << ')'
64
+ unless @clustering_columns.empty?
65
+ cql << ', '
66
+ cql << @clustering_columns.map do |column|
67
+ Util.escape_name(column.name)
68
+ end.join(', ')
69
+ end
70
+ cql << ")\nWITH #{@options.to_cql.split("\n").join("\n ")};"
71
+ end
72
+
73
+ # @private
74
+ def eql?(other)
75
+ other.is_a?(MaterializedView) &&
76
+ super.eql?(other) &&
77
+ @include_all_columns == other.include_all_columns &&
78
+ @where_clause == other.where_clause &&
79
+ @base_table_name == other.base_table.name
80
+ end
81
+ alias == eql?
82
+
83
+ private
84
+
85
+ # We need these accessors for eql? to work, but we don't want random users to
86
+ # get these.
87
+
88
+ # @private
89
+ attr_reader :include_all_columns, :where_clause
90
+ protected :include_all_columns, :where_clause
91
+ end
92
+ end
@@ -0,0 +1,56 @@
1
+ # encoding: utf-8
2
+
3
+ #--
4
+ # Copyright 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
+ # @private
21
+ class NullLogger
22
+ def close(*); end
23
+
24
+ def debug(*); end
25
+
26
+ def debug?
27
+ false
28
+ end
29
+
30
+ def error(*); end
31
+
32
+ def error?
33
+ false
34
+ end
35
+
36
+ def fatal(*); end
37
+
38
+ def fatal?
39
+ false
40
+ end
41
+
42
+ def info(*); end
43
+
44
+ def info?
45
+ false
46
+ end
47
+
48
+ def unknown(*); end
49
+
50
+ def warn(*); end
51
+
52
+ def warn?
53
+ false
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,102 @@
1
+ # encoding: utf-8
2
+
3
+ #--
4
+ # Copyright 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
+ # @private
21
+ module Protocol
22
+ module Formats
23
+ CHAR_FORMAT = 'c'.freeze
24
+ DOUBLE_FORMAT = 'G'.freeze
25
+ FLOAT_FORMAT = 'g'.freeze
26
+ INT_FORMAT = 'N'.freeze
27
+ SHORT_FORMAT = 'n'.freeze
28
+
29
+ BYTES_FORMAT = 'C*'.freeze
30
+ TWO_INTS_FORMAT = 'NN'.freeze
31
+
32
+ # All of the formats above are big-endian (e.g. network-byte-order). Some payloads (custom types) may have
33
+ # little-endian components.
34
+
35
+ DOUBLE_FORMAT_LE = 'E'.freeze
36
+ INT_FORMAT_LE = 'V'.freeze
37
+ SHORT_FORMAT_LE = 'v'.freeze
38
+ end
39
+
40
+ module Constants
41
+ TRUE_BYTE = "\x01".freeze
42
+ FALSE_BYTE = "\x00".freeze
43
+ PROTOCOL_VERSION = "\x01".freeze
44
+ COMPRESSION_OFF = "\x00".freeze
45
+
46
+ SCHEMA_CHANGE_TARGET_KEYSPACE = 'KEYSPACE'.freeze
47
+ SCHEMA_CHANGE_TARGET_TABLE = 'TABLE'.freeze
48
+ SCHEMA_CHANGE_TARGET_UDT = 'TYPE'.freeze
49
+ SCHEMA_CHANGE_TARGET_FUNCTION = 'FUNCTION'.freeze
50
+ SCHEMA_CHANGE_TARGET_AGGREGATE = 'AGGREGATE'.freeze
51
+ end
52
+
53
+ module Versions
54
+ BETA_VERSION = 5
55
+ MAX_SUPPORTED_VERSION = 4
56
+ end
57
+ end
58
+ end
59
+
60
+ require 'cassandra/protocol/cql_byte_buffer'
61
+ require 'cassandra/protocol/response'
62
+ require 'cassandra/protocol/responses/auth_challenge_response'
63
+ require 'cassandra/protocol/responses/auth_success_response'
64
+ require 'cassandra/protocol/responses/error_response'
65
+ require 'cassandra/protocol/responses/already_exists_error_response'
66
+ require 'cassandra/protocol/responses/read_timeout_error_response'
67
+ require 'cassandra/protocol/responses/unavailable_error_response'
68
+ require 'cassandra/protocol/responses/unprepared_error_response'
69
+ require 'cassandra/protocol/responses/write_timeout_error_response'
70
+ require 'cassandra/protocol/responses/ready_response'
71
+ require 'cassandra/protocol/responses/authenticate_response'
72
+ require 'cassandra/protocol/responses/supported_response'
73
+ require 'cassandra/protocol/responses/result_response'
74
+ require 'cassandra/protocol/responses/void_result_response'
75
+ require 'cassandra/protocol/responses/rows_result_response'
76
+ require 'cassandra/protocol/responses/raw_rows_result_response'
77
+ require 'cassandra/protocol/responses/set_keyspace_result_response'
78
+ require 'cassandra/protocol/responses/prepared_result_response'
79
+ require 'cassandra/protocol/responses/schema_change_result_response'
80
+ require 'cassandra/protocol/responses/event_response'
81
+ require 'cassandra/protocol/responses/schema_change_event_response'
82
+ require 'cassandra/protocol/responses/status_change_event_response'
83
+ require 'cassandra/protocol/responses/topology_change_event_response'
84
+ require 'cassandra/protocol/responses/read_failure_error_response'
85
+ require 'cassandra/protocol/responses/write_failure_error_response'
86
+ require 'cassandra/protocol/responses/function_failure_error_response'
87
+ require 'cassandra/protocol/request'
88
+ require 'cassandra/protocol/requests/auth_response_request'
89
+ require 'cassandra/protocol/requests/batch_request'
90
+ require 'cassandra/protocol/requests/startup_request'
91
+ require 'cassandra/protocol/requests/credentials_request'
92
+ require 'cassandra/protocol/requests/options_request'
93
+ require 'cassandra/protocol/requests/register_request'
94
+ require 'cassandra/protocol/requests/query_request'
95
+ require 'cassandra/protocol/requests/void_query_request'
96
+ require 'cassandra/protocol/requests/prepare_request'
97
+ require 'cassandra/protocol/requests/execute_request'
98
+ require 'cassandra/protocol/cql_protocol_handler'
99
+ require 'cassandra/protocol/v1'
100
+ require 'cassandra/protocol/v3'
101
+ require 'cassandra/protocol/v4'
102
+ require 'cassandra/protocol/coder'