regexp

package
v0.0.0-...-784e287 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package regexp provides an implementation to match strings against a set of regexp string filters.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// CacheEnabled determines whether match results are LRU cached to make subsequent matches faster.
	// Cache size is unlimited unless CacheMaxNumEntries is also specified.
	CacheEnabled bool `mapstructure:"cacheenabled"`
	// CacheMaxNumEntries is the max number of entries of the LRU cache that stores match results.
	// CacheMaxNumEntries is ignored if CacheEnabled is false.
	CacheMaxNumEntries int `mapstructure:"cachemaxnumentries"`
}

Config represents the options for a NewFilterSet.

type FilterSet

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

FilterSet encapsulates a set of filters and caches match results. Filters are re2 regex strings. FilterSet is exported for convenience, but has unexported fields and should be constructed through NewFilterSet.

FilterSet satisfies the FilterSet interface from "go.opentelemetry.io/collector/internal/processor/filterset"

func NewFilterSet

func NewFilterSet(filters []string, cfg *Config) (*FilterSet, error)

NewFilterSet constructs a FilterSet of re2 regex strings. If any of the given filters fail to compile into re2, an error is returned.

func (*FilterSet) Matches

func (rfs *FilterSet) Matches(toMatch string) bool

Matches returns true if the given string matches any of the FilterSet's filters. The given string must be fully matched by at least one filter's re2 regex.

Jump to

Keyboard shortcuts

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