Documentation
¶
Index ¶
- Constants
- func ConvertProfileNotAvailableErrToBool(val ref.Val, defaultVal bool) ref.Val
- func HashForContainerProfile(oc objectcache.ObjectCache) func([]ref.Val) string
- func IsProfileNotAvailableErr(val ref.Val) bool
- func NewProfileNotAvailableErr(format string, args ...any) ref.Val
- type CelFunction
- type FunctionCache
- type FunctionCacheConfig
Constants ¶
const ProfileNotAvailableErr = "profile not available"
ProfileNotAvailableErr is a sentinel error message used to indicate that a profile is not yet available. This error is NOT cached, allowing retry when profile becomes available. After the cache layer, this error should be converted to a default value (e.g., false) to allow rule evaluation to continue without failing.
Variables ¶
This section is empty.
Functions ¶
func ConvertProfileNotAvailableErrToBool ¶ added in v0.3.9
ConvertProfileNotAvailableErrToBool converts a "profile not available" error to a boolean value. This should be called AFTER the cache layer to ensure the error is not cached, but the rule evaluation can continue with a default value.
func HashForContainerProfile ¶ added in v0.3.111
func HashForContainerProfile(oc objectcache.ObjectCache) func([]ref.Val) string
HashForContainerProfile returns a function that extracts the SpecHash of the projected profile for the containerID in values[0]. Passing this to WithCache ensures cached results are invalidated whenever the projection spec changes.
func IsProfileNotAvailableErr ¶ added in v0.3.9
IsProfileNotAvailableErr checks if the given value is a "profile not available" error.
Types ¶
type FunctionCache ¶
type FunctionCache struct {
// contains filtered or unexported fields
}
func NewFunctionCache ¶
func NewFunctionCache(config FunctionCacheConfig) *FunctionCache
func (*FunctionCache) ClearCache ¶
func (fc *FunctionCache) ClearCache()
func (*FunctionCache) GetCacheStats ¶
func (fc *FunctionCache) GetCacheStats() (size int)
func (*FunctionCache) WithCache ¶
func (fc *FunctionCache) WithCache(fn CelFunction, functionName string, extraKeyFn ...func([]ref.Val) string) CelFunction
WithCache wraps fn with an LRU result cache keyed by functionName + arguments. extraKeyFn, if provided, is called with the argument slice and its return value is appended to the key — use HashForContainerProfile to invalidate on spec changes.
type FunctionCacheConfig ¶
type FunctionCacheConfig struct {
MaxSize int `mapstructure:"maxSize"`
TTL time.Duration `mapstructure:"ttl"`
}
func DefaultFunctionCacheConfig ¶
func DefaultFunctionCacheConfig() FunctionCacheConfig