From e0066c9c0fe671e0b50f208c41305cf3c80d00b1 Mon Sep 17 00:00:00 2001 From: "rui.zheng" Date: Tue, 21 Nov 2017 14:31:18 +0800 Subject: [PATCH] Node filter only applies to node list of more than one node --- chain.go | 2 +- selector.go | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/chain.go b/chain.go index ca7d15b..9dc672b 100644 --- a/chain.go +++ b/chain.go @@ -53,7 +53,7 @@ func (c *Chain) NodeGroups() []*NodeGroup { } // LastNode returns the last node of the node list. -// If the chain is empty, an empty node is returns. +// If the chain is empty, an empty node will be returned. // If the last node is a node group, the first node in the group will be returned. func (c *Chain) LastNode() Node { if c.IsEmpty() { diff --git a/selector.go b/selector.go index bea2c65..15bbe33 100644 --- a/selector.go +++ b/selector.go @@ -16,7 +16,6 @@ var ( // NodeSelector as a mechanism to pick nodes and mark their status. type NodeSelector interface { Select(nodes []Node, opts ...SelectOption) (Node, error) - // Mark(node Node) } type defaultSelector struct { @@ -130,7 +129,7 @@ type FailFilter struct { // Filter filters nodes. func (f *FailFilter) Filter(nodes []Node) []Node { - if f.MaxFails <= 0 { + if len(nodes) <= 1 || f.MaxFails <= 0 { return nodes } nl := []Node{}