filter

package
v0.0.0-...-e035375 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterFilter

func RegisterFilter(name string, fn NewFilterFunc)

RegisterFilter registers a filter with the given name and config creation callback

func UnmarshalConfig

func UnmarshalConfig(table *ast.Table, config interface{}) error

UnmarshalConfig will unmarshal a Config (either filter.Config or rules.Config) that might contain a Filter field from a toml ast.Table

Types

type AlwaysFalseFilter

type AlwaysFalseFilter struct {
}

AlwaysFalseFilter is a Filter that is always false

func (*AlwaysFalseFilter) Filter

func (f *AlwaysFalseFilter) Filter(key []byte) bool

Filter implements Filter interface

type AlwaysTrueFilter

type AlwaysTrueFilter struct {
}

AlwaysTrueFilter is a Filter that is always true

func (*AlwaysTrueFilter) Filter

func (f *AlwaysTrueFilter) Filter(key []byte) bool

Filter implements Filter interface

type Config

type Config interface {
	Sample() string

	Build() (Filter, error)
}

Config represents the toml configuration of a filter

func NewFilter

func NewFilter(name string) (Config, error)

NewFilter creates a new rule configuration based on its registration name

type ExcludeFilter

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

ExcludeFilter defines a filter to exclude a list of strings

func NewExcludeFilter

func NewExcludeFilter(excludes []string) *ExcludeFilter

NewExcludeFilter creates a new ExcludeFilter

func (*ExcludeFilter) Filter

func (f *ExcludeFilter) Filter(key []byte) bool

Filter implements the Filter interface

type FileFilter

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

FileFilter defines a filter based on a file content

func NewFileFilter

func NewFileFilter(path string) (*FileFilter, error)

NewFileFilter creates a new FileFilter from a path

func (*FileFilter) Filter

func (f *FileFilter) Filter(key []byte) bool

Filter implements Filter interface

type FileFilterConfig

type FileFilterConfig struct {
	Path string
}

FileFilterConfig represents the toml configuration for a filter based on file content

func (*FileFilterConfig) Build

func (c *FileFilterConfig) Build() (Filter, error)

Build implements Config interface

func (*FileFilterConfig) Sample

func (c *FileFilterConfig) Sample() string

Sample implements Config interface

type Filter

type Filter interface {
	Filter(key []byte) bool
}

Filter defines an interface to filter and skip keys when applying rules

func NewStringFilter

func NewStringFilter(config *StringFilterConfig) (Filter, error)

NewStringFilter creates a new StringFilter

func Unmarshal

func Unmarshal(table *ast.Table, name string) (Filter, error)

Unmarshal will unmarshal a filter from a toml table

type FuncFilter

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

FuncFilter is a filter based on a filtering function

func (*FuncFilter) Filter

func (f *FuncFilter) Filter(key []byte) bool

Filter implements Filter interface

type IncludeFilter

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

IncludeFilter defines a filter to only include a list of strings

func NewIncludeFilter

func NewIncludeFilter(includes []string) *IncludeFilter

NewIncludeFilter creates a new IncludeFilter

func (*IncludeFilter) Filter

func (f *IncludeFilter) Filter(key []byte) bool

Filter implements the Filter interface

type ManualConfig

type ManualConfig interface {
	Config

	Unmarshal(table *ast.Table) error
}

ManualConfig represents the toml configuration of a filter that must be unmarshaled manually

type MeasurementFilter

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

MeasurementFilter defines a filter restricted to measurement part of a key

func NewMeasurementFilter

func NewMeasurementFilter(filter Filter) *MeasurementFilter

NewMeasurementFilter creates a new MeasurementFilter

func (*MeasurementFilter) Filter

func (f *MeasurementFilter) Filter(key []byte) bool

Filter implements Filter interface

type NewFilterFunc

type NewFilterFunc func() Config

NewFilterFunc represents a callback to register a filter's configuration to be able to load it from toml

type PatternFilter

type PatternFilter struct {
	Pattern *regexp.Regexp
}

PatternFilter is a Filter based on regexp

func NewPatternFilter

func NewPatternFilter(pattern string) (*PatternFilter, error)

NewPatternFilter creates a new PatternFilter with the given pattern

func (*PatternFilter) Filter

func (f *PatternFilter) Filter(key []byte) bool

Filter implements the Filter interface

type PatternFilterConfig

type PatternFilterConfig struct {
	Pattern string
}

PatternFilterConfig represents the toml configuration of a pattern filter

func (*PatternFilterConfig) Build

func (c *PatternFilterConfig) Build() (Filter, error)

Build implements Config interface

func (*PatternFilterConfig) Sample

func (c *PatternFilterConfig) Sample() string

Sample implement Config interface

type RawSerieFilter

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

RawSerieFilter defines a filter restricted to a serie part of a key as raw bytes

func NewRawSerieFilter

func NewRawSerieFilter(filter Filter) *RawSerieFilter

NewRawSerieFilter creates a new RawSerieFilter

func (*RawSerieFilter) Filter

func (f *RawSerieFilter) Filter(key []byte) bool

Filter implements the Filter interface

type SerieFilter

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

SerieFilter defines a filter restricted to the serie and field part of a key

func NewSerieFilter

func NewSerieFilter(measurementFilter Filter, tagsFilter Filter, fieldFilter Filter) *SerieFilter

NewSerieFilter creates a new SerieFilter

func (*SerieFilter) Filter

func (f *SerieFilter) Filter(key []byte) bool

Filter implements Filter interface

type SerieFilterConfig

type SerieFilterConfig struct {
	Measurement Filter
	Tag         Filter
	Field       Filter
}

SerieFilterConfig represents the toml configuration of a SerieFilter

func (*SerieFilterConfig) Build

func (c *SerieFilterConfig) Build() (Filter, error)

Build implements Config interface

func (*SerieFilterConfig) Sample

func (c *SerieFilterConfig) Sample() string

Sample implements Config interface

type Set

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

Set defines a set of filters that must pass

func (*Set) Filter

func (f *Set) Filter(key []byte) bool

Filter implements the Filter interface

type StringFilterConfig

type StringFilterConfig struct {
	Contains    string
	ContainsAny string
	Equal       string
	EqualFold   string
	HasPrefix   string
	HasSuffix   string
}

StringFilterConfig represents the toml configuration for a filter based on strings functions

func (*StringFilterConfig) Build

func (c *StringFilterConfig) Build() (Filter, error)

Build implements Config interface

func (*StringFilterConfig) Sample

func (c *StringFilterConfig) Sample() string

Sample implements Config interface

type WhereFilter

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

WhereFilter defines a filter to restrict keys based on tag values

func NewWhereFilter

func NewWhereFilter(where map[string]string) (*WhereFilter, error)

NewWhereFilter creates a new WhereFilter based on a map of tags key, value

func (*WhereFilter) Filter

func (f *WhereFilter) Filter(key []byte) bool

Filter implements Filter interface

type WhereFilterConfig

type WhereFilterConfig struct {
	Where map[string]string
}

WhereFilterConfig represents toml configuration for WhereFilter

func (*WhereFilterConfig) Build

func (c *WhereFilterConfig) Build() (Filter, error)

Build implements Config interface

func (*WhereFilterConfig) Sample

func (c *WhereFilterConfig) Sample() string

Sample implements Config interface

func (*WhereFilterConfig) Unmarshal

func (c *WhereFilterConfig) Unmarshal(table *ast.Table) error

Unmarshal implements ManualConfig interface

Jump to

Keyboard shortcuts

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