Documentation ¶
Overview ¶
Package hypermatch is a high-performance Go library that enables rapid matching of a large number of rules against events. Designed for speed and efficiency, hypermatch handles thousands of events per second with low latency.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ValidateRule ¶
func ValidateRule(set ConditionSet) error
ValidateRule validates the given condition set. Returns an error if validation fails.
Types ¶
type Condition ¶
Condition represents a single condition inside a ConditionSet. It defines a Path (=reference to property in an event) and a Pattern to check against the value.
func (Condition) MarshalJSON ¶
MarshalJSON marshals a Condition into an easy readable JSON object
func (*Condition) UnmarshalJSON ¶
UnmarshalJSON unmarshal the JSON back to a Condition
type ConditionSet ¶
type ConditionSet []Condition
ConditionSet represents a rule and consists of one or more items of type Condition
func (ConditionSet) MarshalJSON ¶
func (c ConditionSet) MarshalJSON() ([]byte, error)
MarshalJSON marshals a ConditionSet into an easy readable JSON object
func (*ConditionSet) UnmarshalJSON ¶
func (c *ConditionSet) UnmarshalJSON(data []byte) error
UnmarshalJSON unmarshal the JSON back to a ConditionSet
type HyperMatch ¶
type HyperMatch struct {
// contains filtered or unexported fields
}
func NewHyperMatch ¶
func NewHyperMatch() *HyperMatch
func (*HyperMatch) AddRule ¶
func (m *HyperMatch) AddRule(id RuleIdentifier, conditionSet ConditionSet) error
AddRule adds a new rule to the HyperMatch instance.
The rule is defined by a unique identifier and a set of conditions. The conditions define the properties that must be matched in order for the rule to be triggered.
If the rule is successfully added, the function returns nil. Otherwise, an error is returned.
func (*HyperMatch) Match ¶
func (m *HyperMatch) Match(properties []Property) []RuleIdentifier
Match takes a list of properties and returns a list of rule identifiers that match those properties
type Pattern ¶
type Pattern struct { Type PatternType `json:"type"` Value string `json:"value,omitempty"` Sub []Pattern `json:"sub,omitempty"` }
Pattern defines how a value should be compared. It consists of a Type and either a Value or Sub-patterns depending on the used Type.
func (Pattern) MarshalJSON ¶
MarshalJSON marshals a Pattern into an easy readable JSON object
func (*Pattern) UnmarshalJSON ¶
UnmarshalJSON unmarshal the JSON back to a Pattern
type PatternType ¶
type PatternType int
const ( PatternEquals PatternType = iota PatternPrefix PatternSuffix PatternWildcard PatternAnythingBut PatternAnyOf PatternAllOf PatternUnknown )
func PatternTypeFromString ¶
func PatternTypeFromString(input string) PatternType
func (PatternType) AllValues ¶
func (p PatternType) AllValues() []PatternType
func (PatternType) HasLiteralValue ¶
func (p PatternType) HasLiteralValue() bool
func (PatternType) String ¶
func (p PatternType) String() string
type Property ¶
Property represents a property and a slice of values inside an event. An Event is defined as a slice of Property objects.
type RuleIdentifier ¶
type RuleIdentifier any
RuleIdentifier is a type alias to represent the identifier for a rule, so that the user of hypermatch get identify which of the rules matches an event.