From 2eaced282e7f5468084c846b66b4aef4d8c698c5 Mon Sep 17 00:00:00 2001 From: Jim Witschey Date: Wed, 7 Jun 2017 16:14:00 -0400 Subject: [PATCH] add HFPolicy docs to __init__ --- cassandra/policies.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/cassandra/policies.py b/cassandra/policies.py index 789092b0..6ba8181a 100644 --- a/cassandra/policies.py +++ b/cassandra/policies.py @@ -461,11 +461,11 @@ class WhiteListRoundRobinPolicy(RoundRobinPolicy): class HostFilterPolicy(LoadBalancingPolicy): """ - A :class:`.LoadBalancingPolicy` subclass that takes an instantiated - ``LoadBalancingPolicy`` as a child policy, and a single-argument predicate. - This policy defers to the child policy for hosts where ``predicate(host)`` - is truthy. Hosts for which ``predicate(host)`` is falsey will be considered - :attr:`.IGNORED`, and will not be used in a query plan. + A :class:`.LoadBalancingPolicy` subclass configured with a child policy, + and a single-argument predicate. This policy defers to the child policy for + hosts where ``predicate(host)`` is truthy. Hosts for which + ``predicate(host)`` is falsey will be considered :attr:`.IGNORED`, and will + not be used in a query plan. This can be used in the cases where you need a whitelist or blacklist policy, e.g. to prepare for decommissioning nodes or for testing: @@ -494,6 +494,13 @@ class HostFilterPolicy(LoadBalancingPolicy): _predicate = None def __init__(self, child_policy, predicate): + """ + :param child_policy: an instantiated :class:`.LoadBalancingPolicy` + that this one will defer to. + :param predicate: a one-parameter function that takes a :class:`.Host`. + If it returns a falsey value, the :class:`.Host` will + be :attr:`.IGNORED` and not returned in query plans. + """ super(HostFilterPolicy, self).__init__() self._child_policy = child_policy self._predicate = predicate