Documentation
¶
Overview ¶
Package sequencexl provides a simple xlistd.List implementation that can be used to check in sequence on the child components.
This package is a work in progress and makes no API stability promises.
Index ¶
Examples ¶
Constants ¶
View Source
const ComponentClass = "sequence"
ComponentClass registered.
Variables ¶
This section is empty.
Functions ¶
func Builder ¶
func Builder(defaultCfg Config) xlistd.BuildListFn
Builder returns a builder function.
Types ¶
type List ¶
type List struct {
// contains filtered or unexported fields
}
List implements a composite RBL that checks a group of lists in the order in which they were added.
Example ¶
package main
import (
"context"
"fmt"
"log"
"github.com/luids-io/api/xlist"
"github.com/luids-io/xlist/pkg/xlistd"
"github.com/luids-io/xlist/pkg/xlistd/components/mockxl"
"github.com/luids-io/xlist/pkg/xlistd/components/sequencexl"
)
func main() {
resources := []xlist.Resource{xlist.IPv4}
childs := []xlistd.List{
&mockxl.List{
Identifier: "rbl1",
ResourceList: resources,
Results: []bool{true, false},
Reason: "rbl1",
},
&mockxl.List{
Identifier: "rbl2",
ResourceList: resources,
Fail: true,
},
&mockxl.List{
Identifier: "rbl3",
ResourceList: resources,
Results: []bool{true, false},
Reason: "rbl3",
},
&mockxl.List{
Identifier: "rbl4",
ResourceList: resources,
Results: []bool{true, false},
Reason: "rbl4",
},
}
//constructs sequence rbl
rbl := sequencexl.New("test", childs, resources,
sequencexl.Config{
SkipErrors: true,
FirstResponse: true,
})
for i := 1; i < 5; i++ {
resp, err := rbl.Check(context.Background(), "10.10.10.10", xlist.IPv4)
if err != nil {
log.Fatalln("this should not happen")
}
fmt.Printf("check %v: %v %v\n", i, resp.Result, resp.Reason)
}
// iter 1 ->
// check rbl1 == true -> returns true; now rbl1=false
// iter 2 ->
// check rbl1 == false; now rbl1=true
// check rbl3 == true -> returns true; now rbl3=false
// iter 3 ->
// check rbl1 == true -> returns true; now rbl1=false
// iter 4 ->
// check rbl1 == false; now rbl1= true
// check rbl3 == false; now rbl3=true;
// check rbl4 == true -> returns true; now rbl4=false
}
Output: check 1: true rbl1 check 2: true rbl3 check 3: true rbl1 check 4: true rbl4
Click to show internal directories.
Click to hide internal directories.