lib/aerospike/client.rb in aerospike-2.5.1 vs lib/aerospike/client.rb in aerospike-2.6.0

- old
+ new

@@ -1,15 +1,17 @@ # encoding: utf-8 -# Copyright 2014-2017 Aerospike, Inc. +# Copyright 2014-2018 Aerospike, Inc. # # Portions may be licensed to Aerospike, Inc. under one or more contributor # license agreements. # # Licensed under the Apache License, Version 2.0 (the "License"); you may not # use this file except in compliance with the License. You may obtain a copy of -# the License at http:#www.apache.org/licenses/LICENSE-2.0 +# the License at # +# http://www.apache.org/licenses/LICENSE-2.0 +# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations under # the License. @@ -44,13 +46,13 @@ @default_write_policy = WritePolicy.new @default_scan_policy = ScanPolicy.new @default_query_policy = QueryPolicy.new @default_admin_policy = QueryPolicy.new - hosts = parse_hosts(hosts || ENV["AEROSPIKE_HOSTS"] || "localhost") + hosts = ::Aerospike::Host::Parse.(hosts || ENV['AEROSPIKE_HOSTS'] || 'localhost') policy = create_policy(policy, ClientPolicy) - @cluster = Cluster.new(policy, *hosts) + @cluster = Cluster.new(policy, hosts) @cluster.add_cluster_config_change_listener(self) self.connect if connect self end @@ -86,11 +88,11 @@ ## # Returns list of active server node names in the cluster. def node_names - @cluster.nodes.map(&:get_name) + @cluster.nodes.map(&:name) end def supports_feature?(feature) @cluster.supports_feature?(feature) end @@ -821,26 +823,9 @@ policy when Hash policy_klass.new(policy) else fail TypeError, "policy should be a #{policy_klass.name} instance or a Hash" - end - end - - def parse_hosts(hosts) - case hosts - when Host - [hosts] - when Array - hosts - when String - hosts.split(?,).map { |host| - (addr, port) = host.split(?:) - port ||= 3000 - Host.new(addr, port.to_i) - } - else - fail TypeError, "hosts should be a Host object, an Array of Host objects, or a String" end end def cluster=(cluster) @cluster = cluster