Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConcurrentDict ¶
type ConcurrentDict struct {
// contains filtered or unexported fields
}
ConcurrentDict is just like Dict, but thread-safe and therefore slightly slower.
func NewConcurrentDict ¶
func NewConcurrentDict() *ConcurrentDict
NewConcurrentDict creates a new dict
func (*ConcurrentDict) Add ¶
func (d *ConcurrentDict) Add(v string) int
Add adds a value to the dictionary if not already present and returns the associtated ID
func (*ConcurrentDict) AddSlice ¶
func (d *ConcurrentDict) AddSlice(vv ...string) []int
AddSlice adds a whole slice of values
func (*ConcurrentDict) GetSlice ¶
func (d *ConcurrentDict) GetSlice(vv ...string) []int
GetSlice is a read-only operation, only returns known IDs
type Conjunction ¶
type Conjunction struct {
// contains filtered or unexported fields
}
Conjunction combines two or more rules into by creating a logical AND
func (*Conjunction) Match ¶
func (r *Conjunction) Match(vals *intset.Set) bool
Match tests if the rule is qualified
func (*Conjunction) String ¶
func (r *Conjunction) String() string
String returns a human-readable description
type Dict ¶
Dict is a simple helper to to turn convert strings into integers using dictionary encoding. Dict instances are NOT thread-safe because they are populated sequentially on Qualifier creation and then only read.
If your use case requires rules to call Add operations concurrently please use (the slower but) thread-safe ConcurrentDict
func (Dict) Add ¶
Add adds a value to the dictionary if not already present and returns the associtated ID
type Disjunction ¶
type Disjunction struct {
// contains filtered or unexported fields
}
Disjunction combines two or more rules into by creating a logical OR
func (*Disjunction) Match ¶
func (r *Disjunction) Match(vals *intset.Set) bool
Match tests if the rule is qualified
func (*Disjunction) String ¶
func (r *Disjunction) String() string
String returns a human-readable description
type Exclusion ¶
type Exclusion struct {
// contains filtered or unexported fields
}
Exclusion rules require none of the values to be present in the fact
type Fact ¶
Fact is an interface of a fact that may be passed to a qualifier. Each fact must implement a Get(string) method which receives the attribute name and must return either a string or an int slice, depending on the attribute definition.
type Inclusion ¶
type Inclusion struct {
// contains filtered or unexported fields
}
Inclusion rules require either of values to be present in the fact
type Negation ¶
type Negation struct {
// contains filtered or unexported fields
}
Negation inverts a Rule
type Qualifier ¶
type Qualifier struct {
// contains filtered or unexported fields
}
Qualifier represents a rule engine that can match a fact against a list of rule-sets using a fixed set of attributes
Example setup:
q := qfy.New([]string{"country", "months"})
q.Feed(11, map[string]Rule{ "country": qfy.Include(q, []string{"GB"}), "months": qfy.Include(q, []int{2015, 2014}), })
q.Feed(12, map[string]Rule{ "country": qfy.Exclude(q, []string{"US"}), "months": qfy.And(qfy.Between(2010, 2015), qfy.Exclude(q, []int{2012})), })