-
Notifications
You must be signed in to change notification settings - Fork 4
Description
Description
Currently almost all mixed lists, like []string with action=block|allow or custom structs like field policies (ex.: endpoints, ipfilters, fieldpolicies) are parsed on-the-fly, this means that for example endpoints have to be split based on prefix ! into allowed and blocked.
This can be a bit expensive and often is unnecessary, since it doesn't change (apart from config reloads) this could greatly improve performance!
Solution
CUSTOM PARSERS. (well actually these are just transforms again)
This means probably some implementation of this:
type ACCESS struct {
ENDPOINTS Endpoint `koanf:"endpoints" parser:"allowed-blocked-parser"`
}
type Endpoint struct {
Allowed []string
Blocked []string
}
func allowedBlockedParser(key string, value any) (string, any) {
if strings.HasPrefix(value.(string), "!") {
return key + ".allowed", value
}
return key + ".blocked", value
}But we already have
transform:"func-name"
Why can't we use that?
Well, this is because transforms only take into account a section of the key like url instead of say api.url,
in my head it is just adding another parameter for the fullkey and done, but I know I would hit some kind of wall again.
Alternatives
Ignore the performance loss