Documentation
¶
Index ¶
- Constants
- func BuildMetadataColumnRef(field string) string
- func BuildPatternCondition(columnRef, patternType, patternValue string, startParam int) (string, []interface{}, error)
- func EvaluateMetadataRuleInMemory(rule EnrichmentRule, metadata map[string]interface{}) bool
- func ExtractMetadataKeys(metadata map[string]interface{}) []string
- func GetNestedMetadataValue(metadata map[string]interface{}, field string) interface{}
- func MatchWildcard(pattern, value string) bool
- func RenumberParameters(sql string) string
- func ValidateRule(rule EnrichmentRule) error
- type AssetSignature
- type CandidateRule
- type EnrichmentRule
- type Evaluator
- type RuleTarget
- type RuleType
Constants ¶
const ( PatternTypeExact = "exact" PatternTypeWildcard = "wildcard" PatternTypeRegex = "regex" PatternTypePrefix = "prefix" )
const ( TargetTypeAssetType = "asset_type" TargetTypeProvider = "provider" TargetTypeTag = "tag" TargetTypeMetadataKey = "metadata_key" TargetTypeQuery = "query" )
Variables ¶
This section is empty.
Functions ¶
func BuildMetadataColumnRef ¶
BuildMetadataColumnRef builds a PostgreSQL column reference for a metadata field path.
func BuildPatternCondition ¶
func BuildPatternCondition(columnRef, patternType, patternValue string, startParam int) (string, []interface{}, error)
BuildPatternCondition builds a SQL condition for pattern matching. startParam is the first $N parameter number to use.
func EvaluateMetadataRuleInMemory ¶
func EvaluateMetadataRuleInMemory(rule EnrichmentRule, metadata map[string]interface{}) bool
EvaluateMetadataRuleInMemory checks if an asset matches a metadata rule without DB access.
func ExtractMetadataKeys ¶
ExtractMetadataKeys extracts the top-level keys from metadata.
func GetNestedMetadataValue ¶
GetNestedMetadataValue extracts a value from nested metadata using dot notation.
func MatchWildcard ¶
MatchWildcard performs simple wildcard matching (* = any characters).
func RenumberParameters ¶
RenumberParameters renumbers SQL parameters from $2, $3, ... to $1, $2, ...
func ValidateRule ¶
func ValidateRule(rule EnrichmentRule) error
ValidateRule validates the rule configuration based on its type.
Types ¶
type AssetSignature ¶
type AssetSignature struct {
ID string
Type string
Providers []string
Tags []string
MetadataKeys []string
}
AssetSignature contains the key fields used for candidate rule lookup.
type CandidateRule ¶
type CandidateRule struct {
RuleID string
}
type EnrichmentRule ¶
type EnrichmentRule interface {
GetID() string
GetRuleType() RuleType
GetQueryExpression() *string
GetMetadataField() *string
GetPatternType() *string
GetPatternValue() *string
GetIsEnabled() bool
}
EnrichmentRule is the common interface implemented by asset rules.
type Evaluator ¶
type Evaluator struct {
// contains filtered or unexported fields
}
func NewEvaluator ¶
NewEvaluator creates a new rule evaluator.
func (*Evaluator) EvaluateRuleForAsset ¶
func (e *Evaluator) EvaluateRuleForAsset(ctx context.Context, rule EnrichmentRule, assetID string) (bool, error)
EvaluateRuleForAsset checks if a specific asset matches a rule.
func (*Evaluator) ExecuteRule ¶
ExecuteRule runs a rule and returns matching asset IDs.
type RuleTarget ¶
func ExtractRuleTargets ¶
func ExtractRuleTargets(rule EnrichmentRule) []RuleTarget
ExtractRuleTargets analyzes a rule and extracts what it's targeting.