cache

package
v0.3.10 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2025 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
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

func ConvertProfileNotAvailableErrToBool(val ref.Val, defaultVal bool) ref.Val

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 IsProfileNotAvailableErr added in v0.3.9

func IsProfileNotAvailableErr(val ref.Val) bool

IsProfileNotAvailableErr checks if the given value is a "profile not available" error.

func NewProfileNotAvailableErr added in v0.3.9

func NewProfileNotAvailableErr(format string, args ...any) ref.Val

NewProfileNotAvailableErr creates a new "profile not available" error. This error will NOT be cached, allowing the function to be re-evaluated when the profile becomes available.

Types

type CelFunction

type CelFunction func(...ref.Val) ref.Val

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) CelFunction

type FunctionCacheConfig

type FunctionCacheConfig struct {
	MaxSize int           `mapstructure:"maxSize"`
	TTL     time.Duration `mapstructure:"ttl"`
}

func DefaultFunctionCacheConfig

func DefaultFunctionCacheConfig() FunctionCacheConfig

Jump to

Keyboard shortcuts

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