Skip to content

Commit 8d48c55

Browse files
author
Bulat Shakirzyanov
committed
[RUBY-12] rename Cassandra.connect to Cassandra.cluster
1 parent 08f3fc1 commit 8d48c55

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+137
-136
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Breaking changes:
1414

1515
* Most of the error classes have changed
1616
* Connections to hosts in remote datacenters will be disabled by default
17+
* Cassandra.connect has been renamed to Cassandra.cluster to avoid confusion
1718

1819
# 1.0.0.beta.3
1920

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ __Note__: JRuby 1.6 is not officially supported, although 1.6.8 should work.
3535
```ruby
3636
require 'cassandra'
3737

38-
cluster = Cassandra.connect # connects to localhost by default
38+
cluster = Cassandra.cluster # connects to localhost by default
3939

4040
cluster.each_host do |host| # automatically discovers all peers
4141
puts "Host #{host.ip}: id=#{host.id} datacenter=#{host.datacenter} rack=#{host.rack}"
@@ -57,7 +57,7 @@ The host you specify is just a seed node, the driver will automatically discover
5757

5858
Read more:
5959

60-
* [`Cassandra.connect` options](http://datastax.github.io/ruby-driver/api/#connect-class_method)
60+
* [`Cassandra.cluster` options](http://datastax.github.io/ruby-driver/api/#cluster-class_method)
6161
* [`Session#execute_async` options](http://datastax.github.io/ruby-driver/api/session/#execute_async-instance_method)
6262
* [Usage documentation](http://datastax.github.io/ruby-driver/features)
6363

benchmarking/async-prepared-insert-ruby-driver.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def setup
3131

3232
def connect_to_cluster
3333
puts "#{Time.now - start} Connecting to cluster..."
34-
@cluster = Cassandra.connect(hosts: ['127.0.0.1'])
34+
@cluster = Cassandra.cluster(hosts: ['127.0.0.1'])
3535
@session = @cluster.connect("simplex")
3636
@session.execute(Cassandra::Statements::Simple.new("TRUNCATE songs"))
3737
@statement = @session.prepare("INSERT INTO songs (id, title, album, artist, tags) VALUES (?, 'Dummy song-id', 'Track 1', 'Unknown Artist', {'soundtrack', '1985'});")

benchmarking/async-prepared-select-ruby-driver.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
class PreparedSelectRubyDriver < Benchmark
2323
def connect_to_cluster
2424
puts "#{Time.now - start} Connecting to cluster..."
25-
@cluster = Cassandra.connect(hosts: ['127.0.0.1'])
25+
@cluster = Cassandra.cluster(hosts: ['127.0.0.1'])
2626
@session = @cluster.connect("simplex")
2727
@statement = @session.prepare('SELECT * FROM songs')
2828
end

benchmarking/async-unprepared-insert-ruby-driver.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def setup
3131

3232
def connect_to_cluster
3333
puts "#{Time.now - start} Connecting to cluster..."
34-
@cluster = Cassandra.connect(hosts: ['127.0.0.1'])
34+
@cluster = Cassandra.cluster(hosts: ['127.0.0.1'])
3535
@session = @cluster.connect("simplex")
3636
@session.execute(Cassandra::Statements::Simple.new("TRUNCATE songs"))
3737
end

benchmarking/async-unprepared-select-ruby-driver.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
class UnpreparedSelectRubyDriver < Benchmark
2323
def connect_to_cluster
2424
puts "#{Time.now - start} Connecting to cluster..."
25-
@cluster = Cassandra.connect(hosts: ['127.0.0.1'])
25+
@cluster = Cassandra.cluster(hosts: ['127.0.0.1'])
2626
@session = @cluster.connect("simplex")
2727
end
2828

benchmarking/sync-prepared-insert-ruby-driver.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def setup
3131

3232
def connect_to_cluster
3333
puts "#{Time.now - start} Connecting to cluster..."
34-
@cluster = Cassandra.connect(hosts: ['127.0.0.1'])
34+
@cluster = Cassandra.cluster(hosts: ['127.0.0.1'])
3535
@session = @cluster.connect("simplex")
3636
@session.execute(Cassandra::Statements::Simple.new("TRUNCATE songs"))
3737
@statement = @session.prepare("INSERT INTO songs (id, title, album, artist, tags) VALUES (?, 'Dummy song-id', 'Track 1', 'Unknown Artist', {'soundtrack', '1985'});")

benchmarking/sync-prepared-select-ruby-driver.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
class PreparedSelectRubyDriver < Benchmark
2323
def connect_to_cluster
2424
puts "#{Time.now - start} Connecting to cluster..."
25-
@cluster = Cassandra.connect(hosts: ['127.0.0.1'])
25+
@cluster = Cassandra.cluster(hosts: ['127.0.0.1'])
2626
@session = @cluster.connect("simplex")
2727
@statement = @session.prepare('SELECT COUNT(*) FROM songs')
2828
end

benchmarking/sync-unprepared-insert-ruby-driver.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def setup
3131

3232
def connect_to_cluster
3333
puts "#{Time.now - start} Connecting to cluster..."
34-
@cluster = Cassandra.connect(hosts: ['127.0.0.1'])
34+
@cluster = Cassandra.cluster(hosts: ['127.0.0.1'])
3535
@session = @cluster.connect("simplex")
3636
@session.execute(Cassandra::Statements::Simple.new("TRUNCATE songs"))
3737
end

benchmarking/sync-unprepared-select-ruby-driver.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
class UnpreparedSelectRubyDriver < Benchmark
2323
def connect_to_cluster
2424
puts "#{Time.now - start} Connecting to cluster..."
25-
@cluster = Cassandra.connect(hosts: ['127.0.0.1'])
25+
@cluster = Cassandra.cluster(hosts: ['127.0.0.1'])
2626
@session = @cluster.connect("simplex")
2727
end
2828

examples/cql-rb-wrapper.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,6 @@ def close
6161
end
6262
end
6363

64-
cluster = Cassandra.connect
64+
cluster = Cassandra.cluster
6565
session = cluster.connect
6666
client = Client.new(session)

features/README.md

+11-11
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,21 @@
22

33
## Connecting and Discovering Nodes
44

5-
Ruby driver will connect to 127.0.0.1 if no `:hosts` given to `Cassandra.connect`. It will automatically discover all peers and add them to cluster metadata.
5+
Ruby driver will connect to 127.0.0.1 if no `:hosts` given to `Cassandra.cluster`. It will automatically discover all peers and add them to cluster metadata.
66

77
```ruby
88
require 'cassandra'
99

10-
cluster = Cassandra.connect
10+
cluster = Cassandra.cluster
1111

1212
cluster.each_hosts do |host|
1313
puts "Host #{host.ip}: id=#{host.id} datacenter=#{host.datacenter} rack=#{host.rack}"
1414
end
1515
```
1616

17-
You can also specify a list of seed nodes to connect to. The set of IP addresses we pass to the `Cassandra.connect` is simply an initial set of contact points. After the driver connects to one of these nodes, it will automatically discover the rest of the nodes in the cluster, so you don’t need to list every node in your cluster.
17+
You can also specify a list of seed nodes to connect to. The set of IP addresses we pass to the `Cassandra.cluster` is simply an initial set of contact points. After the driver connects to one of these nodes, it will automatically discover the rest of the nodes in the cluster, so you don’t need to list every node in your cluster.
1818

19-
[Read more in the api docs](http://datastax.github.io/ruby-driver/api/#connect-class_method)
19+
[Read more in the api docs](http://datastax.github.io/ruby-driver/api/#cluster-class_method)
2020

2121
## Executing Queries
2222

@@ -204,10 +204,10 @@ end
204204
You can specify the default consistency to use when you create a new `Cluster`:
205205

206206
```ruby
207-
client = Cassandra.connect(consistency: :all)
207+
client = Cassandra.cluster(consistency: :all)
208208
```
209209

210-
[Read more about default consistency](http://datastax.github.io/ruby-driver/api/#connect-class_method)
210+
[Read more about default consistency](http://datastax.github.io/ruby-driver/api/#cluster-class_method)
211211

212212
Consistency can also be passed to `Session#execute` and `Session#execute_async`
213213

@@ -232,18 +232,18 @@ Consistency is ignored for `USE`, `TRUNCATE`, `CREATE` and `ALTER` statements, a
232232

233233
## Compression
234234

235-
The CQL protocol supports frame compression, which can give you a performance boost if your requests or responses are big. To enable it you can specify compression to use in `Cassandra.connect`.
235+
The CQL protocol supports frame compression, which can give you a performance boost if your requests or responses are big. To enable it you can specify compression to use in `Cassandra.cluster`.
236236

237237
Cassandra currently supports two compression algorithms: Snappy and LZ4. ruby driver supports both, but in order to use them you will have to install the [snappy](http://rubygems.org/gems/snappy) or [lz4-ruby](http://rubygems.org/gems/lz4-ruby) gems separately. Once it's installed you can enable compression like this:
238238

239239
```ruby
240-
cluster = Cassandra.connect(compression: :snappy)
240+
cluster = Cassandra.cluster(compression: :snappy)
241241
```
242242

243243
or
244244

245245
```ruby
246-
cluster = Cassandra.connect(compression: :lz4)
246+
cluster = Cassandra.cluster(compression: :lz4)
247247
```
248248

249249
Which one should you choose? On paper the LZ4 algorithm is more efficient and the one Cassandra defaults to for SSTable compression. They both achieve roughly the same compression ratio, but LZ4 does it quicker.
@@ -255,7 +255,7 @@ You can pass a standard Ruby logger to the client to get some more information a
255255
```ruby
256256
require 'logger'
257257

258-
cluster = Cassandra.connect(logger: Logger.new($stderr))
258+
cluster = Cassandra.cluster(logger: Logger.new($stderr))
259259
```
260260

261261
Most of the logging will be when the driver connects and discovers new nodes, when connections fail and so on. The logging is designed to not cause much overhead and only relatively rare events are logged (e.g. normal requests are not logged).
@@ -306,7 +306,7 @@ A Cluster instance allows to configure different important aspects of the way co
306306
```ruby
307307
require 'cassandra'
308308

309-
cluster = Cassandra.connect(
309+
cluster = Cassandra.cluster(
310310
:hosts => ['10.1.1.3', '10.1.1.4', '10.1.1.5'],
311311
:load_balancing_policy => Cassandra::LoadBalancing::Policies::DCAwareRoundRobin.new("US_EAST")
312312
)

features/asynchronous_io/executing_queries.feature

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ Feature: Executing queries asynchronously
4747
"""ruby
4848
require 'cassandra'
4949
50-
cluster = Cassandra.connect
50+
cluster = Cassandra.cluster
5151
session = cluster.connect("simplex")
5252
future = session.execute_async("SELECT * FROM songs")
5353
@@ -74,7 +74,7 @@ Feature: Executing queries asynchronously
7474
"""ruby
7575
require 'cassandra'
7676
77-
cluster = Cassandra.connect
77+
cluster = Cassandra.cluster
7878
session = cluster.connect("simplex")
7979
count = 10
8080

features/asynchronous_io/preparing_statements.feature

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ Feature: Preparing statements asynchronously
8787
"""ruby
8888
require 'cassandra'
8989
90-
cluster = Cassandra.connect
90+
cluster = Cassandra.cluster
9191
session = cluster.connect("simplex")
9292
9393
# prepare 2 statements in parallel

features/basics/batch_statements.feature

+4-4
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Feature: Batch statements
2525
"""ruby
2626
require 'cassandra'
2727
28-
cluster = Cassandra.connect
28+
cluster = Cassandra.cluster
2929
3030
at_exit { cluster.close }
3131
@@ -83,7 +83,7 @@ Feature: Batch statements
8383
"""ruby
8484
require 'cassandra'
8585
86-
cluster = Cassandra.connect
86+
cluster = Cassandra.cluster
8787
8888
at_exit { cluster.close }
8989
@@ -138,7 +138,7 @@ Feature: Batch statements
138138
"""ruby
139139
require 'cassandra'
140140
141-
cluster = Cassandra.connect
141+
cluster = Cassandra.cluster
142142
143143
at_exit { cluster.close }
144144
@@ -194,7 +194,7 @@ Feature: Batch statements
194194
"""ruby
195195
require 'cassandra'
196196
197-
cluster = Cassandra.connect
197+
cluster = Cassandra.cluster
198198
at_exit { cluster.close }
199199
200200
session = cluster.connect("simplex")

features/basics/datatypes.feature

+4-4
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Feature: Datatypes
3636
"""ruby
3737
require 'cassandra'
3838
39-
cluster = Cassandra.connect
39+
cluster = Cassandra.cluster
4040
session = cluster.connect("simplex")
4141
4242
row = session.execute("SELECT * FROM mytable").first
@@ -84,7 +84,7 @@ Feature: Datatypes
8484
"""ruby
8585
require 'cassandra'
8686
87-
cluster = Cassandra.connect
87+
cluster = Cassandra.cluster
8888
session = cluster.connect("simplex")
8989
9090
row = session.execute("SELECT * FROM mytable").first
@@ -135,7 +135,7 @@ Feature: Datatypes
135135
require 'cassandra'
136136
require 'time'
137137
138-
cluster = Cassandra.connect
138+
cluster = Cassandra.cluster
139139
session = cluster.connect("simplex")
140140
141141
row = session.execute("SELECT * FROM mytable").first
@@ -180,7 +180,7 @@ Feature: Datatypes
180180
require 'cassandra'
181181
require 'time'
182182
183-
cluster = Cassandra.connect
183+
cluster = Cassandra.cluster
184184
session = cluster.connect("simplex")
185185
186186
row = session.execute("SELECT * FROM user").first

features/basics/prepared_statements.feature

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Feature: Prepared statements
2222
"""ruby
2323
require 'cassandra'
2424
25-
cluster = Cassandra.connect
25+
cluster = Cassandra.cluster
2626
session = cluster.connect("simplex")
2727
insert = session.prepare(
2828
"INSERT INTO playlists (id, song_id, title, artist, album) " \
@@ -123,7 +123,7 @@ Feature: Prepared statements
123123
"""ruby
124124
require 'cassandra'
125125
126-
cluster = Cassandra.connect
126+
cluster = Cassandra.cluster
127127
session = cluster.connect("simplex")
128128
select = session.prepare("SELECT * FROM playlists LIMIT ?")
129129
limits = [1, 2, 3]

features/basics/result_paging.feature

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ Feature: Result paging
3838
"""ruby
3939
require 'cassandra'
4040
41-
cluster = Cassandra.connect
41+
cluster = Cassandra.cluster
4242
session = cluster.connect("simplex")
4343
result = session.execute("SELECT * FROM test", page_size: 5)
4444
@@ -103,7 +103,7 @@ Feature: Result paging
103103
end
104104
end
105105
106-
cluster = Cassandra.connect
106+
cluster = Cassandra.cluster
107107
session = cluster.connect("simplex")
108108
select = session.prepare("SELECT * FROM test")
109109
future = session.execute_async(select, page_size: 5)

features/debugging/execution_info.feature

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ Feature: Execution information
4646
"""ruby
4747
require 'cassandra'
4848
49-
cluster = Cassandra.connect
49+
cluster = Cassandra.cluster
5050
5151
at_exit { cluster.close }
5252
@@ -105,7 +105,7 @@ Feature: Execution information
105105
require 'cassandra'
106106
require 'retrying_at_a_given_consistency_policy'
107107
108-
cluster = Cassandra.connect(retry_policy: RetryingAtAGivenConsistencyPolicy.new(:one))
108+
cluster = Cassandra.cluster(retry_policy: RetryingAtAGivenConsistencyPolicy.new(:one))
109109
session = cluster.connect("simplex")
110110
execution = session.execute("SELECT * FROM songs", consistency: :all).execution_info
111111

features/debugging/request_tracing.feature

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ Feature: Request tracing
4646
"""ruby
4747
require 'cassandra'
4848
49-
cluster = Cassandra.connect
49+
cluster = Cassandra.cluster
5050
session = cluster.connect("simplex")
5151
execution = session.execute("SELECT * FROM songs").execution_info
5252
@@ -69,7 +69,7 @@ Feature: Request tracing
6969
"""ruby
7070
require 'cassandra'
7171
72-
cluster = Cassandra.connect
72+
cluster = Cassandra.cluster
7373
session = cluster.connect("simplex")
7474
execution = session.execute("SELECT * FROM songs", :trace => true).execution_info
7575
trace = execution.trace

0 commit comments

Comments
 (0)