update config parsing
This commit is contained in:
@ -1,5 +1,9 @@
|
||||
package chain
|
||||
|
||||
type Chainer interface {
|
||||
Route(network, address string) *Route
|
||||
}
|
||||
|
||||
type Chain struct {
|
||||
groups []*NodeGroup
|
||||
}
|
||||
@ -8,16 +12,12 @@ func (c *Chain) AddNodeGroup(group *NodeGroup) {
|
||||
c.groups = append(c.groups, group)
|
||||
}
|
||||
|
||||
func (c *Chain) GetRoute() (r *route) {
|
||||
return c.GetRouteFor("tcp", "")
|
||||
}
|
||||
|
||||
func (c *Chain) GetRouteFor(network, address string) (r *route) {
|
||||
func (c *Chain) Route(network, address string) (r *Route) {
|
||||
if c == nil || len(c.groups) == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
r = &route{}
|
||||
r = &Route{}
|
||||
for _, group := range c.groups {
|
||||
node := group.Next()
|
||||
if node == nil {
|
||||
@ -32,14 +32,10 @@ func (c *Chain) GetRouteFor(network, address string) (r *route) {
|
||||
WithRoute(r)
|
||||
node = node.Copy()
|
||||
node.Transport = tr
|
||||
r = &route{}
|
||||
r = &Route{}
|
||||
}
|
||||
|
||||
r.AddNode(node)
|
||||
r.addNode(node)
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
func (c *Chain) IsEmpty() bool {
|
||||
return c == nil || len(c.groups) == 0
|
||||
}
|
||||
|
Reference in New Issue
Block a user