rules

package
v0.0.0-...-ec279c9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 15, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package rules provides primitives for working with routing rules.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PrefixTrie

type PrefixTrie struct {
	// contains filtered or unexported fields
}

PrefixTrie efficiently checks if a slice of bytes contains one of the prefixes prevoiusly added to the tree.

func NewPrefixTrie

func NewPrefixTrie() *PrefixTrie

NewPrefixTrie makes a new instance of a PrefixTrie.

func (*PrefixTrie) Add

func (t *PrefixTrie) Add(s []byte)

Add a prefix to the trie

func (*PrefixTrie) Check

func (t *PrefixTrie) Check(s []byte) bool

Check if string s contains any of the prefixes

type Rule

type Rule struct {
	Regexs     []string
	Prefixes   []string
	Targets    []target.ClusterTarget
	Continue   bool
	CompiledRE []*regexp.Regexp

	PrefixTrie *PrefixTrie
	// contains filtered or unexported fields
}

Rule is a routing rule.

func (Rule) Match

func (rl Rule) Match(r *rec.RecBytes, measureRegex bool) bool

Match a record with any of the rule regexps

type Rules

type Rules struct {
	// contains filtered or unexported fields
}

Rules represent all the routing rules/routing table.

func Build

func Build(crs *conf.Rules, clusters target.Clusters, measureRegex bool, ms *metrics.Prom) (Rules, error)

Build reads rules from config, compiles them.

func TestBuild

func TestBuild(crs conf.Rules, clusters map[string]*target.TestTarget, measureRegex bool, ms *metrics.Prom) (Rules, error)

TestBuild makes a set of rules for testing.

func (Rules) RouteRec

func (rs Rules) RouteRec(r *rec.RecBytes, lg *zap.Logger)

RouteRec a record by following the rules

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL