metrics: add chain error counter

This commit is contained in:
ginuerzh
2022-03-16 22:18:26 +08:00
parent 6b2ccaad38
commit 26d322379d
3 changed files with 39 additions and 2 deletions

View File

@ -5,9 +5,17 @@ type Chainer interface {
}
type Chain struct {
name string
groups []*NodeGroup
}
func NewChain(name string, groups ...*NodeGroup) *Chain {
return &Chain{
name: name,
groups: groups,
}
}
func (c *Chain) AddNodeGroup(group *NodeGroup) {
c.groups = append(c.groups, group)
}
@ -17,7 +25,9 @@ func (c *Chain) Route(network, address string) (r *Route) {
return
}
r = &Route{}
r = &Route{
chain: c,
}
for _, group := range c.groups {
node := group.Next()
if node == nil {