filter

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Please check out the _example filter for a pattern for creating new filters.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Chain

type Chain struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func (*Chain) Add

func (c *Chain) Add(f Filterer) error

func (*Chain) Config added in v0.2.1

func (c *Chain) Config() interface{}

func (*Chain) EventErrorCount added in v1.1.2

func (c *Chain) EventErrorCount() int

func (*Chain) EventErrorVelocity added in v1.1.2

func (c *Chain) EventErrorVelocity() int

func (*Chain) EventFilterCount added in v1.1.2

func (c *Chain) EventFilterCount() int

func (*Chain) EventFilterVelocity added in v1.1.2

func (c *Chain) EventFilterVelocity() int

func (*Chain) EventSuccessCount added in v1.1.2

func (c *Chain) EventSuccessCount() int

func (*Chain) EventSuccessVelocity added in v1.1.2

func (c *Chain) EventSuccessVelocity() int

func (*Chain) EventTs added in v1.1.2

func (c *Chain) EventTs() int64

func (*Chain) Filter

func (c *Chain) Filter(e event.Event) []event.Event

func (*Chain) Filterers

func (c *Chain) Filterers() []Filterer

func (*Chain) Name added in v0.2.1

func (c *Chain) Name() string

func (*Chain) Plugin added in v0.2.1

func (c *Chain) Plugin() string

func (*Chain) Tenant added in v0.3.0

func (c *Chain) Tenant() tenant.Id

type Chainer

type Chainer interface {
	Filterer

	// Add will add a filterer to the chain
	Add(f Filterer) error
	Filterers() []Filterer
}

Chainer

type ChainerMock

type ChainerMock struct {
	// AddFunc mocks the Add method.
	AddFunc func(f Filterer) error

	// ConfigFunc mocks the Config method.
	ConfigFunc func() interface{}

	// FilterFunc mocks the Filter method.
	FilterFunc func(e event.Event) []event.Event

	// FilterersFunc mocks the Filterers method.
	FilterersFunc func() []Filterer

	// NameFunc mocks the Name method.
	NameFunc func() string

	// PluginFunc mocks the Plugin method.
	PluginFunc func() string

	// TenantFunc mocks the Tenant method.
	TenantFunc func() tenant.Id
	// contains filtered or unexported fields
}

ChainerMock is a mock implementation of Chainer.

func TestSomethingThatUsesChainer(t *testing.T) {

	// make and configure a mocked Chainer
	mockedChainer := &ChainerMock{
		AddFunc: func(f Filterer) error {
			panic("mock out the Add method")
		},
		ConfigFunc: func() interface{} {
			panic("mock out the Config method")
		},
		FilterFunc: func(e event.Event) []event.Event {
			panic("mock out the Filter method")
		},
		FilterersFunc: func() []Filterer {
			panic("mock out the Filterers method")
		},
		NameFunc: func() string {
			panic("mock out the Name method")
		},
		PluginFunc: func() string {
			panic("mock out the Plugin method")
		},
		TenantFunc: func() tenant.Id {
			panic("mock out the Tenant method")
		},
	}

	// use mockedChainer in code that requires Chainer
	// and then make assertions.

}

func (*ChainerMock) Add

func (mock *ChainerMock) Add(f Filterer) error

Add calls AddFunc.

func (*ChainerMock) AddCalls

func (mock *ChainerMock) AddCalls() []struct {
	F Filterer
}

AddCalls gets all the calls that were made to Add. Check the length with:

len(mockedChainer.AddCalls())

func (*ChainerMock) Config added in v0.2.1

func (mock *ChainerMock) Config() interface{}

Config calls ConfigFunc.

func (*ChainerMock) ConfigCalls added in v0.2.1

func (mock *ChainerMock) ConfigCalls() []struct {
}

ConfigCalls gets all the calls that were made to Config. Check the length with:

len(mockedChainer.ConfigCalls())

func (*ChainerMock) EventErrorCount added in v1.1.2

func (mock *ChainerMock) EventErrorCount() int

func (*ChainerMock) EventErrorVelocity added in v1.1.2

func (mock *ChainerMock) EventErrorVelocity() int

func (*ChainerMock) EventFilterCount added in v1.1.2

func (mock *ChainerMock) EventFilterCount() int

func (*ChainerMock) EventFilterVelocity added in v1.1.2

func (mock *ChainerMock) EventFilterVelocity() int

func (*ChainerMock) EventSuccessCount added in v1.1.2

func (mock *ChainerMock) EventSuccessCount() int

func (*ChainerMock) EventSuccessVelocity added in v1.1.2

func (mock *ChainerMock) EventSuccessVelocity() int

func (*ChainerMock) EventTs added in v1.1.2

func (mock *ChainerMock) EventTs() int64

func (*ChainerMock) Filter

func (mock *ChainerMock) Filter(e event.Event) []event.Event

Filter calls FilterFunc.

func (*ChainerMock) FilterCalls

func (mock *ChainerMock) FilterCalls() []struct {
	E event.Event
}

FilterCalls gets all the calls that were made to Filter. Check the length with:

len(mockedChainer.FilterCalls())

func (*ChainerMock) Filterers

func (mock *ChainerMock) Filterers() []Filterer

Filterers calls FilterersFunc.

func (*ChainerMock) FilterersCalls

func (mock *ChainerMock) FilterersCalls() []struct {
}

FilterersCalls gets all the calls that were made to Filterers. Check the length with:

len(mockedChainer.FilterersCalls())

func (*ChainerMock) Name added in v0.2.1

func (mock *ChainerMock) Name() string

Name calls NameFunc.

func (*ChainerMock) NameCalls added in v0.2.1

func (mock *ChainerMock) NameCalls() []struct {
}

NameCalls gets all the calls that were made to Name. Check the length with:

len(mockedChainer.NameCalls())

func (*ChainerMock) Plugin added in v0.2.1

func (mock *ChainerMock) Plugin() string

Plugin calls PluginFunc.

func (*ChainerMock) PluginCalls added in v0.2.1

func (mock *ChainerMock) PluginCalls() []struct {
}

PluginCalls gets all the calls that were made to Plugin. Check the length with:

len(mockedChainer.PluginCalls())

func (*ChainerMock) Tenant added in v0.3.0

func (mock *ChainerMock) Tenant() tenant.Id

Tenant calls TenantFunc.

func (*ChainerMock) TenantCalls added in v0.3.0

func (mock *ChainerMock) TenantCalls() []struct {
}

TenantCalls gets all the calls that were made to Tenant. Check the length with:

len(mockedChainer.TenantCalls())

type Filterer

type Filterer interface {
	Filter(e event.Event) []event.Event
	Config() interface{}
	Name() string
	Plugin() string
	Tenant() tenant.Id
	EventSuccessCount() int
	EventSuccessVelocity() int
	EventFilterCount() int
	EventFilterVelocity() int
	EventErrorCount() int
	EventErrorVelocity() int
	EventTs() int64
}

Filterer defines the interface that a filterer must implement

type FiltererMock

type FiltererMock struct {
	// ConfigFunc mocks the Config method.
	ConfigFunc func() interface{}

	// FilterFunc mocks the Filter method.
	FilterFunc func(e event.Event) []event.Event

	// NameFunc mocks the Name method.
	NameFunc func() string

	// PluginFunc mocks the Plugin method.
	PluginFunc func() string

	// TenantFunc mocks the Tenant method.
	TenantFunc func() tenant.Id
	// contains filtered or unexported fields
}

FiltererMock is a mock implementation of Filterer.

func TestSomethingThatUsesFilterer(t *testing.T) {

	// make and configure a mocked Filterer
	mockedFilterer := &FiltererMock{
		ConfigFunc: func() interface{} {
			panic("mock out the Config method")
		},
		FilterFunc: func(e event.Event) []event.Event {
			panic("mock out the Filter method")
		},
		NameFunc: func() string {
			panic("mock out the Name method")
		},
		PluginFunc: func() string {
			panic("mock out the Plugin method")
		},
		TenantFunc: func() tenant.Id {
			panic("mock out the Tenant method")
		},
	}

	// use mockedFilterer in code that requires Filterer
	// and then make assertions.

}

func (*FiltererMock) Config added in v0.2.1

func (mock *FiltererMock) Config() interface{}

Config calls ConfigFunc.

func (*FiltererMock) ConfigCalls added in v0.2.1

func (mock *FiltererMock) ConfigCalls() []struct {
}

ConfigCalls gets all the calls that were made to Config. Check the length with:

len(mockedFilterer.ConfigCalls())

func (*FiltererMock) EventErrorCount added in v1.1.2

func (mock *FiltererMock) EventErrorCount() int

func (*FiltererMock) EventErrorVelocity added in v1.1.2

func (mock *FiltererMock) EventErrorVelocity() int

func (*FiltererMock) EventFilterCount added in v1.1.2

func (mock *FiltererMock) EventFilterCount() int

func (*FiltererMock) EventFilterVelocity added in v1.1.2

func (mock *FiltererMock) EventFilterVelocity() int

func (*FiltererMock) EventSuccessCount added in v1.1.2

func (mock *FiltererMock) EventSuccessCount() int

func (*FiltererMock) EventSuccessVelocity added in v1.1.2

func (mock *FiltererMock) EventSuccessVelocity() int

func (*FiltererMock) EventTs added in v1.1.2

func (mock *FiltererMock) EventTs() int64

func (*FiltererMock) Filter

func (mock *FiltererMock) Filter(e event.Event) []event.Event

Filter calls FilterFunc.

func (*FiltererMock) FilterCalls

func (mock *FiltererMock) FilterCalls() []struct {
	E event.Event
}

FilterCalls gets all the calls that were made to Filter. Check the length with:

len(mockedFilterer.FilterCalls())

func (*FiltererMock) Name added in v0.2.1

func (mock *FiltererMock) Name() string

Name calls NameFunc.

func (*FiltererMock) NameCalls added in v0.2.1

func (mock *FiltererMock) NameCalls() []struct {
}

NameCalls gets all the calls that were made to Name. Check the length with:

len(mockedFilterer.NameCalls())

func (*FiltererMock) Plugin added in v0.2.1

func (mock *FiltererMock) Plugin() string

Plugin calls PluginFunc.

func (*FiltererMock) PluginCalls added in v0.2.1

func (mock *FiltererMock) PluginCalls() []struct {
}

PluginCalls gets all the calls that were made to Plugin. Check the length with:

len(mockedFilterer.PluginCalls())

func (*FiltererMock) Tenant added in v0.3.0

func (mock *FiltererMock) Tenant() tenant.Id

Tenant calls TenantFunc.

func (*FiltererMock) TenantCalls added in v0.3.0

func (mock *FiltererMock) TenantCalls() []struct {
}

TenantCalls gets all the calls that were made to Tenant. Check the length with:

len(mockedFilterer.TenantCalls())

type Hasher

type Hasher interface {
	// FiltererHash calculates the hash of a filterer based on the
	// given configuration
	FiltererHash(config interface{}) (string, error)
}

Hasher defines the hashing interface that a receiver needs to implement

type HasherMock

type HasherMock struct {
	// FiltererHashFunc mocks the FiltererHash method.
	FiltererHashFunc func(config interface{}) (string, error)
	// contains filtered or unexported fields
}

HasherMock is a mock implementation of Hasher.

func TestSomethingThatUsesHasher(t *testing.T) {

	// make and configure a mocked Hasher
	mockedHasher := &HasherMock{
		FiltererHashFunc: func(config interface{}) (string, error) {
			panic("mock out the FiltererHash method")
		},
	}

	// use mockedHasher in code that requires Hasher
	// and then make assertions.

}

func (*HasherMock) FiltererHash

func (mock *HasherMock) FiltererHash(config interface{}) (string, error)

FiltererHash calls FiltererHashFunc.

func (*HasherMock) FiltererHashCalls

func (mock *HasherMock) FiltererHashCalls() []struct {
	Config interface{}
}

FiltererHashCalls gets all the calls that were made to FiltererHash. Check the length with:

len(mockedHasher.FiltererHashCalls())

type InvalidArgumentError

type InvalidArgumentError struct {
	Err error
}

func (*InvalidArgumentError) Error

func (e *InvalidArgumentError) Error() string

func (*InvalidArgumentError) Unwrap

func (e *InvalidArgumentError) Unwrap() error

type InvalidConfigError

type InvalidConfigError struct {
	Err error
}

InvalidConfigError is returned when a configuration parameter results in a plugin error

func (*InvalidConfigError) Error

func (e *InvalidConfigError) Error() string

func (*InvalidConfigError) Unwrap

func (e *InvalidConfigError) Unwrap() error

type NewFilterer

type NewFilterer interface {
	Hasher

	// NewFilterer returns an object that implements the Filterer interface
	NewFilterer(tid tenant.Id, plugin string, name string, config interface{}, secrets secret.Vault, tableSyncer syncer.DeltaSyncer) (Filterer, error)
}

NewFilterer defines the interface on how to to create a new filterer

type NewFiltererMock

type NewFiltererMock struct {
	// FiltererHashFunc mocks the FiltererHash method.
	FiltererHashFunc func(config interface{}) (string, error)

	// NewFiltererFunc mocks the NewFilterer method.
	NewFiltererFunc func(tid tenant.Id, plugin string, name string, config interface{}, secrets secret.Vault, tableSyncer syncer.DeltaSyncer) (Filterer, error)
	// contains filtered or unexported fields
}

NewFiltererMock is a mock implementation of NewFilterer.

func TestSomethingThatUsesNewFilterer(t *testing.T) {

	// make and configure a mocked NewFilterer
	mockedNewFilterer := &NewFiltererMock{
		FiltererHashFunc: func(config interface{}) (string, error) {
			panic("mock out the FiltererHash method")
		},
		NewFiltererFunc: func(tid tenant.Id, plugin string, name string, config interface{}, secrets secret.Vault) (Filterer, error) {
			panic("mock out the NewFilterer method")
		},
	}

	// use mockedNewFilterer in code that requires NewFilterer
	// and then make assertions.

}

func (*NewFiltererMock) FiltererHash

func (mock *NewFiltererMock) FiltererHash(config interface{}) (string, error)

FiltererHash calls FiltererHashFunc.

func (*NewFiltererMock) FiltererHashCalls

func (mock *NewFiltererMock) FiltererHashCalls() []struct {
	Config interface{}
}

FiltererHashCalls gets all the calls that were made to FiltererHash. Check the length with:

len(mockedNewFilterer.FiltererHashCalls())

func (*NewFiltererMock) NewFilterer

func (mock *NewFiltererMock) NewFilterer(tid tenant.Id, plugin string, name string, config interface{}, secrets secret.Vault, tableSyncer syncer.DeltaSyncer) (Filterer, error)

NewFilterer calls NewFiltererFunc.

func (*NewFiltererMock) NewFiltererCalls

func (mock *NewFiltererMock) NewFiltererCalls() []struct {
	Tid     tenant.Id
	Plugin  string
	Name    string
	Config  interface{}
	Secrets secret.Vault
}

NewFiltererCalls gets all the calls that were made to NewFilterer. Check the length with:

len(mockedNewFilterer.NewFiltererCalls())

Directories

Path Synopsis
Install go-enum by `go get -u github.com/searKing/golang/tools/go-enum`
Install go-enum by `go get -u github.com/searKing/golang/tools/go-enum`

Jump to

Keyboard shortcuts

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