Tutorial Intro
Some practical tools、 algorithms written in Go

p2c grpc balancer
// example
func test() {
cc, err := grpc.Dial(r.Scheme()+":///test.server",
grpc.WithDefaultServiceConfig(fmt.Sprintf(`{"loadBalancingConfig": [{"%s":{}}]}`, p2c.Name)))
if err != nil {
t.Fatalf("failed to dial: %v", err)
}
defer cc.Close()
}
ast rule engine
supported operator
comparator:
>>=<<===bitwise:
&|^bitwiseShift:
<<>>additive:
+-multiplicative:
*/%prefix:
!(NOT)-(NEGATE)logic:
&&||func call:
(),func(do func call with build in function and custom function)params type:
IdentNumberStringBoolarray,struct(DO Not supportfunc)recursive params call with
.:map.mapKey.mapKey.arrayIndex.structFiledName(foo.bar.2.Name)Link
// example
import (
. "github.com/sado0823/go-kitx/kit/rule"
)
func main(){
expr := `foo + 1 > bar`
param := map[string]interface{}{
"foo": 5,
"bar": 6,
}
res, err := Do(context.Background(), expr, param)
if err != nil {
panic(err)
}
}