class Cassandra::LoadBalancing::Policy

@abstract Actual load balancing policies don't need to extend this class,

only implement its methods. This class exists for documentation
purposes only.

Public Instance Methods

distance(host) click to toggle source

Returns a distance that determines how many connections (if any) the driver will open to the host.

@param host [Cassandra::Host] a host instance @return [Symbol] distance to host. Must be one of

{Cassandra::LoadBalancing::DISTANCES}
   # File lib/cassandra/load_balancing.rb
68 def distance(host)
69 end
host_down(host) click to toggle source

@see Cassandra::Listener#host_down

   # File lib/cassandra/load_balancing.rb
51 def host_down(host)
52 end
host_found(host) click to toggle source

@see Cassandra::Listener#host_found

   # File lib/cassandra/load_balancing.rb
55 def host_found(host)
56 end
host_lost(host) click to toggle source

@see Cassandra::Listener#host_lost

   # File lib/cassandra/load_balancing.rb
59 def host_lost(host)
60 end
host_up(host) click to toggle source

@see Cassandra::Listener#host_up

   # File lib/cassandra/load_balancing.rb
47 def host_up(host)
48 end
inspect() click to toggle source

@private

   # File lib/cassandra/load_balancing.rb
85 def inspect
86   "#<#{self.class.name}:0x#{object_id.to_s(16)}>"
87 end
plan(keyspace, statement, options) click to toggle source

Load balancing plan is used to determine the order in which hosts

should be tried in case of a network failure.

@note Hosts that should be ignored, must not be included in the Plan

@param keyspace [String] current keyspace of the {Cassandra::Session} @param statement [Cassandra::Statement] actual statement to be executed @param options [Cassandra::Execution::Options] execution options to be used @raise [NotImplementedError] override this method to return a plan @return [Cassandra::LoadBalancing::Plan] a load balancing plan

   # File lib/cassandra/load_balancing.rb
81 def plan(keyspace, statement, options)
82 end
setup(cluster) click to toggle source

Allows policy to initialize with the cluster instance. This method is called once before connecting to the cluster.

@param cluster [Cassandra::Cluster] current cluster instance @return [void]

   # File lib/cassandra/load_balancing.rb
34 def setup(cluster)
35 end
teardown(cluster) click to toggle source

Allows policy to release any external resources it might be holding. This method is called once the cluster has been terminated after calling {Cassandra::Cluster#close}

@param cluster [Cassandra::Cluster] current cluster instance @return [void]

   # File lib/cassandra/load_balancing.rb
43 def teardown(cluster)
44 end