Node filter only applies to node list of more than one node

This commit is contained in:
rui.zheng 2017-11-21 14:31:18 +08:00
parent 4cdf5d5b8b
commit e0066c9c0f
2 changed files with 2 additions and 3 deletions

View File

@ -53,7 +53,7 @@ func (c *Chain) NodeGroups() []*NodeGroup {
} }
// LastNode returns the last node of the node list. // 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. // If the last node is a node group, the first node in the group will be returned.
func (c *Chain) LastNode() Node { func (c *Chain) LastNode() Node {
if c.IsEmpty() { if c.IsEmpty() {

View File

@ -16,7 +16,6 @@ var (
// NodeSelector as a mechanism to pick nodes and mark their status. // NodeSelector as a mechanism to pick nodes and mark their status.
type NodeSelector interface { type NodeSelector interface {
Select(nodes []Node, opts ...SelectOption) (Node, error) Select(nodes []Node, opts ...SelectOption) (Node, error)
// Mark(node Node)
} }
type defaultSelector struct { type defaultSelector struct {
@ -130,7 +129,7 @@ type FailFilter struct {
// Filter filters nodes. // Filter filters nodes.
func (f *FailFilter) Filter(nodes []Node) []Node { func (f *FailFilter) Filter(nodes []Node) []Node {
if f.MaxFails <= 0 { if len(nodes) <= 1 || f.MaxFails <= 0 {
return nodes return nodes
} }
nl := []Node{} nl := []Node{}