Skip to content

Commit bee6603

Browse files
committed
RUBY-266 - expose execution profiles through cluster object
* Also bump version to 3.1.0.rc.1 in preparation of 3.1.0 release.
1 parent f86255c commit bee6603

File tree

4 files changed

+20
-7
lines changed

4 files changed

+20
-7
lines changed

Gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: .
33
specs:
4-
cassandra-driver (3.0.4.rc.1)
4+
cassandra-driver (3.1.0.rc.1)
55
ione (~> 1.2)
66

77
GEM

lib/cassandra/cluster.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,12 @@ def close
288288
close_async.get
289289
end
290290

291+
# @param name [String] Name of profile to retrieve
292+
# @return [Cassandra::Execution::Profile] execution profile of the given name.
293+
def execution_profile(name)
294+
@profile_manager.profiles[name]
295+
end
296+
291297
# @private
292298
def inspect
293299
"#<#{self.class.name}:0x#{object_id.to_s(16)} " \

lib/cassandra/execution/profile_manager.rb

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,11 @@ def initialize(default_profile, profiles)
3333

3434
@load_balancing_policies = Set.new
3535
@load_balancing_policies << default_profile.load_balancing_policy if default_profile.load_balancing_policy
36+
@profiles = {DEFAULT_EXECUTION_PROFILE => default_profile}
3637

37-
profiles.each_value do |profile|
38-
@load_balancing_policies << profile.load_balancing_policy if profile.load_balancing_policy
39-
profile.merge_from(default_profile)
38+
profiles.each do |name, profile|
39+
add_profile(name, profile)
4040
end
41-
42-
@profiles = profiles.merge({DEFAULT_EXECUTION_PROFILE => default_profile})
4341
end
4442

4543
def default_profile
@@ -59,6 +57,15 @@ def distance(host)
5957
return :ignore
6058
end
6159

60+
# NOTE: It's only safe to call add_profile when setting up the cluster object. In particular,
61+
# this is only ok before calling Driver#connect.
62+
# @private
63+
def add_profile(name, profile)
64+
@profiles[name] = profile
65+
@load_balancing_policies << profile.load_balancing_policy if profile.load_balancing_policy
66+
profile.merge_from(default_profile)
67+
end
68+
6269
# @private
6370
def inspect
6471
"#<#{self.class.name}:0x#{object_id.to_s(16)} " \

lib/cassandra/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@
1717
#++
1818

1919
module Cassandra
20-
VERSION = '3.0.4.rc.1'.freeze
20+
VERSION = '3.1.0.rc.1'.freeze
2121
end

0 commit comments

Comments
 (0)