Documentation
¶
Index ¶
Constants ¶
View Source
const (
EqualFunctionName = "go-trellis::filters::equals"
)
defaults function names
Variables ¶
View Source
var ( ErrInvalidFilterName = errors.TN(namespace, 1000, "invalid filter name") ErrFilterFunctionEqualNil = errors.TN(namespace, 1001, "filter function should not be nil") ErrNotSupportedFilterType = errors.TN(namespace, 1002, "filter type not supported") ErrNotExistsInputParams = errors.TN(namespace, 1003, "not exists input params") ErrNotExistsTargetParams = errors.TN(namespace, 1004, "not exists target params") ErrFailedExecFilterFunction = errors.TN(namespace, 1005, "failed exec filter function: {{.err}}") ErrFailedExecTimeout = errors.TN(namespace, 1006, "exec filter function timeout") ErrTimeoutMustAboveZero = errors.TN(namespace, 1007, "set timeout must above zero") ErrUnknownCompareType = errors.TN(namespace, 1008, "unknown compare type") )
errors
Functions ¶
func CompareEqualsFunc ¶ added in v0.0.3
func CompareEqualsFunc(input, target FilterValues) (filtered bool, err error)
CompareEqualsFunc compare values must equal
Types ¶
type CompareFunc ¶ added in v0.0.3
type CompareFunc func(input, target FilterValues) (filtered bool, err error)
CompareFunc is the function you want to compare input values with target values Input Values is the k:v maps with input values Target Values is the k:v maps with filter values return bool is filtered return error if compare function has internal error you can write you campare functions like FilterFunc, then manager.AddFilterFunc(name, filterFunc)
type CompareType ¶ added in v0.0.3
type CompareType int
CompareType compare type
const ( CompareTypeSequence CompareType = iota CompareTypeConsistent )
CompareType defines
type FilterParams ¶ added in v0.0.3
type FilterParams struct {
Names []string
Type CompareType
}
FilterParams filter params
type FilterRepo ¶
type FilterRepo interface {
// Set compare timeout: must be above zero.
SetCompareTimeout(time.Duration) error
// add a compare function : CompareFunc
AddCompareFunc(name string, cf CompareFunc)
// remove a compare funcation by name
RemoveCompareFunc(name string)
// get compare function
GetCompareFunc(name string) CompareFunc
// compare input values and filter values
Compare(filter *FilterParams, input, target FilterValues) (bool, error)
}
FilterRepo filter repo
type FilterValues ¶ added in v0.0.3
type FilterValues map[string]interface{}
FilterValues type map[string]interface{}
Click to show internal directories.
Click to hide internal directories.
