Documentation
¶
Index ¶
- Variables
- type Add
- type And
- type BinaryOp
- type BinaryOpFunc
- type BinaryOpType
- type Bool
- type Bytes
- type Check
- type Contains
- type Date
- type Div
- type Equal
- type Expression
- type Fact
- type FactSet
- type GreaterOrEqual
- type GreaterThan
- type Integer
- type Intersection
- type InvalidRuleError
- type Length
- type LessOrEqual
- type LessThan
- type MatchedVariables
- type Mul
- type Negate
- type Op
- type OpType
- type Or
- type Parens
- type Predicate
- type Prefix
- type Regex
- type Rule
- type Set
- type String
- type Sub
- type Suffix
- type SymbolDebugger
- func (d SymbolDebugger) Check(c Check) string
- func (d SymbolDebugger) CheckQuery(r Rule) string
- func (d SymbolDebugger) Expression(e Expression) string
- func (d SymbolDebugger) FactSet(s *FactSet) string
- func (d SymbolDebugger) Predicate(p Predicate) string
- func (d SymbolDebugger) Rule(r Rule) string
- func (d SymbolDebugger) World(w *World) string
- type SymbolTable
- func (t *SymbolTable) Clone() *SymbolTable
- func (t *SymbolTable) Extend(other *SymbolTable)
- func (t *SymbolTable) Index(s string) uint64
- func (t *SymbolTable) Insert(s string) String
- func (t *SymbolTable) IsDisjoint(other *SymbolTable) bool
- func (t *SymbolTable) Len() int
- func (t *SymbolTable) SplitOff(at int) *SymbolTable
- func (t *SymbolTable) Str(sym String) string
- func (t *SymbolTable) Sym(s string) Term
- func (t *SymbolTable) Var(v Variable) string
- type Term
- type TermType
- type UnaryOp
- type UnaryOpFunc
- type UnaryOpType
- type Union
- type Value
- type Variable
- type World
- func (w *World) AddFact(f Fact)
- func (w *World) AddRule(r Rule)
- func (w *World) Clone() *World
- func (w *World) Facts() *FactSet
- func (w *World) Query(pred Predicate) *FactSet
- func (w *World) QueryRule(rule Rule, syms *SymbolTable) *FactSet
- func (w *World) ResetRules()
- func (w *World) Rules() []Rule
- func (w *World) Run(syms *SymbolTable) error
- type WorldOption
Constants ¶
This section is empty.
Variables ¶
var ( ErrWorldRunLimitMaxFacts = errors.New("datalog: world runtime limit: too many facts") ErrWorldRunLimitMaxIterations = errors.New("datalog: world runtime limit: too many iterations") ErrWorldRunLimitTimeout = errors.New("datalog: world runtime limit: timeout") )
var ( ErrExprDivByZero = errors.New("datalog: Div by zero") ErrInt64Overflow = errors.New("datalog: expression overflowed int64") )
var DEFAULT_SYMBOLS = [...]string{
"read",
"write",
"resource",
"operation",
"right",
"time",
"role",
"owner",
"tenant",
"namespace",
"user",
"team",
"service",
"admin",
"email",
"group",
"member",
"ip_address",
"client",
"client_ip",
"domain",
"path",
"version",
"cluster",
"node",
"hostname",
"nonce",
"query",
}
var OFFSET = 1024
Functions ¶
This section is empty.
Types ¶
type Add ¶
type Add struct{}
Add performs the addition of left + right and returns the result. It requires left and right to be Integer.
func (Add) Type ¶
func (Add) Type() BinaryOpType
type And ¶
type And struct{}
And performs a logical AND between left and right and returns a Bool. It requires left and right to be Bool.
func (And) Type ¶
func (And) Type() BinaryOpType
type BinaryOp ¶
type BinaryOp struct {
BinaryOpFunc
}
type BinaryOpFunc ¶
type BinaryOpFunc interface { Type() BinaryOpType Eval(left, right Term, symbols *SymbolTable) (Term, error) }
type BinaryOpType ¶
type BinaryOpType byte
const ( BinaryLessThan BinaryOpType = iota BinaryLessOrEqual BinaryGreaterThan BinaryGreaterOrEqual BinaryEqual BinaryContains BinaryPrefix BinarySuffix BinaryRegex BinaryAdd BinarySub BinaryMul BinaryDiv BinaryAnd BinaryOr BinaryIntersection BinaryUnion )
type Contains ¶
type Contains struct{}
Contains returns true when the right value exists in the left Set. The right value must be an Integer, Bytes, String or Symbol. The left value must be a Set, containing elements of right type.
func (Contains) Type ¶
func (Contains) Type() BinaryOpType
type Div ¶
type Div struct{}
Div performs the division of left / right and returns the result. It requires left and right to be Integer.
func (Div) Type ¶
func (Div) Type() BinaryOpType
type Equal ¶
type Equal struct{}
Equal returns true when left and right are equal. It requires left and right to have the same concrete type and only accepts Integer, Bytes or String.
func (Equal) Type ¶
func (Equal) Type() BinaryOpType
type Expression ¶
type Expression []Op
func (*Expression) Evaluate ¶
func (e *Expression) Evaluate(values map[Variable]*Term, symbols *SymbolTable) (Term, error)
func (*Expression) Print ¶
func (e *Expression) Print(symbols *SymbolTable) string
type GreaterOrEqual ¶
type GreaterOrEqual struct{}
GreaterOrEqual returns true when left is greater than right. It requires left and right to have the same concrete type and only accepts Integer and Date.
func (GreaterOrEqual) Eval ¶
func (GreaterOrEqual) Eval(left Term, right Term, symbols *SymbolTable) (Term, error)
func (GreaterOrEqual) Type ¶
func (GreaterOrEqual) Type() BinaryOpType
type GreaterThan ¶
type GreaterThan struct{}
GreaterThan returns true when left is greater than right. It requires left and right to have the same concrete type and only accepts Integer.
func (GreaterThan) Eval ¶
func (GreaterThan) Eval(left Term, right Term, symbols *SymbolTable) (Term, error)
func (GreaterThan) Type ¶
func (GreaterThan) Type() BinaryOpType
type Intersection ¶
type Intersection struct{}
Intersection returns the intersection of two sets
func (Intersection) Eval ¶
func (Intersection) Eval(left Term, right Term, symbols *SymbolTable) (Term, error)
func (Intersection) Type ¶
func (Intersection) Type() BinaryOpType
type InvalidRuleError ¶
func (InvalidRuleError) Error ¶
func (e InvalidRuleError) Error() string
type Length ¶
type Length struct{}
Length returns the length of a value. It accepts String, Bytes and Set
func (Length) Type ¶
func (Length) Type() UnaryOpType
type LessOrEqual ¶
type LessOrEqual struct{}
LessOrEqual returns true when left is less or equal than right. It requires left and right to have the same concrete type and only accepts Integer and Date.
func (LessOrEqual) Eval ¶
func (LessOrEqual) Eval(left Term, right Term, symbols *SymbolTable) (Term, error)
func (LessOrEqual) Type ¶
func (LessOrEqual) Type() BinaryOpType
type LessThan ¶
type LessThan struct{}
LessThan returns true when left is less than right. It requires left and right to have the same concrete type and only accepts Integer.
func (LessThan) Type ¶
func (LessThan) Type() BinaryOpType
type MatchedVariables ¶
func (MatchedVariables) Clone ¶
func (m MatchedVariables) Clone() MatchedVariables
func (MatchedVariables) Complete ¶
func (m MatchedVariables) Complete() map[Variable]*Term
type Mul ¶
type Mul struct{}
Mul performs the multiplication of left * right and returns the result. It requires left and right to be Integer.
func (Mul) Type ¶
func (Mul) Type() BinaryOpType
type Negate ¶
type Negate struct{}
Negate returns the negation of a value. It only accepts a Bool value.
func (Negate) Type ¶
func (Negate) Type() UnaryOpType
type Or ¶
type Or struct{}
Or performs a logical OR between left and right and returns a Bool. It requires left and right to be Bool.
func (Or) Type ¶
func (Or) Type() BinaryOpType
type Parens ¶
type Parens struct{}
Parens allows expression priority and grouping (like parenthesis in math operations) it is a no-op, but is used to print back the expressions properly, putting their value inside parenthesis.
func (Parens) Type ¶
func (Parens) Type() UnaryOpType
type Prefix ¶
type Prefix struct{}
Prefix returns true when the left string starts with the right string. left and right must be String.
func (Prefix) Type ¶
func (Prefix) Type() BinaryOpType
type Regex ¶
type Regex struct{}
Regex returns true when the right string is a regexp and left matches against it. left and right must be String.
func (Regex) Type ¶
func (Regex) Type() BinaryOpType
type Rule ¶
type Rule struct { Head Predicate Body []Predicate Expressions []Expression }
type Sub ¶
type Sub struct{}
Sub performs the substraction of left - right and returns the result. It requires left and right to be Integer.
func (Sub) Type ¶
func (Sub) Type() BinaryOpType
type Suffix ¶
type Suffix struct{}
Suffix returns true when the left string ends with the right string. left and right must be String.
func (Suffix) Type ¶
func (Suffix) Type() BinaryOpType
type SymbolDebugger ¶
type SymbolDebugger struct {
*SymbolTable
}
func (SymbolDebugger) Check ¶
func (d SymbolDebugger) Check(c Check) string
func (SymbolDebugger) CheckQuery ¶
func (d SymbolDebugger) CheckQuery(r Rule) string
func (SymbolDebugger) Expression ¶
func (d SymbolDebugger) Expression(e Expression) string
func (SymbolDebugger) FactSet ¶
func (d SymbolDebugger) FactSet(s *FactSet) string
func (SymbolDebugger) Predicate ¶
func (d SymbolDebugger) Predicate(p Predicate) string
func (SymbolDebugger) Rule ¶
func (d SymbolDebugger) Rule(r Rule) string
func (SymbolDebugger) World ¶
func (d SymbolDebugger) World(w *World) string
type SymbolTable ¶
type SymbolTable []string
func (*SymbolTable) Clone ¶
func (t *SymbolTable) Clone() *SymbolTable
func (*SymbolTable) Extend ¶
func (t *SymbolTable) Extend(other *SymbolTable)
Extend insert symbols from the given SymbolTable in the receiving one excluding any Symbols already existing
func (*SymbolTable) Index ¶
func (t *SymbolTable) Index(s string) uint64
func (*SymbolTable) Insert ¶
func (t *SymbolTable) Insert(s string) String
func (*SymbolTable) IsDisjoint ¶
func (t *SymbolTable) IsDisjoint(other *SymbolTable) bool
IsDisjoint returns true if receiver has no elements in common with other. This is equivalent to checking for an empty intersection.
func (*SymbolTable) Len ¶
func (t *SymbolTable) Len() int
func (*SymbolTable) SplitOff ¶
func (t *SymbolTable) SplitOff(at int) *SymbolTable
SplitOff returns a newly allocated slice containing the elements in the range [at, len). After the call, the receiver will be left containing the elements [0, at) with its previous capacity unchanged.
func (*SymbolTable) Str ¶
func (t *SymbolTable) Str(sym String) string
func (*SymbolTable) Sym ¶
func (t *SymbolTable) Sym(s string) Term
func (*SymbolTable) Var ¶
func (t *SymbolTable) Var(v Variable) string
type UnaryOp ¶
type UnaryOp struct {
UnaryOpFunc
}
type UnaryOpFunc ¶
type UnaryOpFunc interface { Type() UnaryOpType Eval(value Term, symbols *SymbolTable) (Term, error) }
type UnaryOpType ¶
type UnaryOpType byte
const ( UnaryNegate UnaryOpType = iota UnaryParens UnaryLength )
type Union ¶
type Union struct{}
Intersection returns the intersection of two sets
func (Union) Type ¶
func (Union) Type() BinaryOpType
type World ¶
type World struct {
// contains filtered or unexported fields
}
func NewWorld ¶
func NewWorld(opts ...WorldOption) *World
func (*World) ResetRules ¶
func (w *World) ResetRules()
func (*World) Run ¶
func (w *World) Run(syms *SymbolTable) error
type WorldOption ¶
type WorldOption func(w *World)
func WithMaxDuration ¶
func WithMaxDuration(maxDuration time.Duration) WorldOption
func WithMaxFacts ¶
func WithMaxFacts(maxFacts int) WorldOption
func WithMaxIterations ¶
func WithMaxIterations(maxIterations int) WorldOption