Documentation
¶
Index ¶
- Constants
- Variables
- func CanonicalizeMap(raw json.RawMessage) (map[string]string, error)
- func CanonicalizeScalar(raw json.RawMessage, dataType DataType) (string, error)
- func CanonicalizeSet(raw json.RawMessage) ([]string, error)
- type DataType
- type OperationArgs
- type Reader
- type ResolveResult
- type ValkeyAdapter
- func (r *ValkeyAdapter) AddElementToSet(variableKey string, hubName string, value string) valkey.Completed
- func (r *ValkeyAdapter) AuditStreamExpiry() time.Duration
- func (r *ValkeyAdapter) BulkSetMap(variableKey string, hubName string, values map[string]string) valkey.Completed
- func (r *ValkeyAdapter) DeleteKeysWithPrefixUsingScan(ctx context.Context, keep map[string]struct{}, hubName string) error
- func (r *ValkeyAdapter) DeleteString(variableKey string, hubName string) valkey.Completed
- func (r *ValkeyAdapter) Exists(ctx context.Context, variableKey string, hubName string) (bool, error)
- func (r *ValkeyAdapter) GetMap(ctx context.Context, variableKey string, hubName string) (map[string]string, error)
- func (r *ValkeyAdapter) GetMapAsString(ctx context.Context, variableKey string, hubName string) (string, error)
- func (r *ValkeyAdapter) GetMetaHashSet(ctx context.Context, variableKey string, hubName string) (string, bool, error)
- func (r *ValkeyAdapter) GetMetaPriorityList(ctx context.Context, variableKey string, hubName string) ([]string, bool, error)
- func (r *ValkeyAdapter) GetOrCreateMetaHashSet(ctx context.Context, variableKey string, hubName string, ...) (string, bool, error)
- func (r *ValkeyAdapter) GetOrCreateMetaPriorityList(ctx context.Context, variableKey string, hubName string, variableRefs []string) ([]string, bool, error)
- func (r *ValkeyAdapter) GetSetAsStringSlice(ctx context.Context, variableKey string, hubName string) ([]string, error)
- func (r *ValkeyAdapter) GetString(ctx context.Context, variableKey string, hubName string) (string, bool, error)
- func (r *ValkeyAdapter) IntDecrBy(variableKey string, hubName string, value int64) valkey.Completed
- func (r *ValkeyAdapter) IntIncrBy(variableKey string, hubName string, value int64) valkey.Completed
- func (r *ValkeyAdapter) RemoveElementFromSet(variableKey string, hubName string, value string) valkey.Completed
- func (r *ValkeyAdapter) RemoveMapEntry(variableKey string, hubName string, field string) valkey.Completed
- func (r *ValkeyAdapter) SetMapEntry(variableKey string, hubName string, field string, value string) valkey.Completed
- func (r *ValkeyAdapter) SetString(variableKey string, hubName string, value string) valkey.Completed
- type ValkeyAdapterOption
Constants ¶
const ( // ValkeyWrongTypeOrNotFoundError is returned by custom Valkey module commands // when the key is missing or has an incompatible type. ValkeyWrongTypeOrNotFoundError = "WRONGTYPE_OR_NOTFOUND" // PriorityListGetOrCreateCommand fetches or initializes a module-backed priority list. PriorityListGetOrCreateCommand = "PRIORITYLIST.GETORCREATE" // PriorityListGetCommand fetches a module-backed priority list. PriorityListGetCommand = "PRIORITYLIST.GET" // HashSetGetOrCreateCommand fetches or initializes a module-backed hash set value. HashSetGetOrCreateCommand = "HASHSET.GETORCREATE" // HashSetLookupCommand fetches a module-backed hash set value. HashSetLookupCommand = "HASHSET.LOOKUP" )
Variables ¶
var ErrInvalidDefault = errors.New("invalid default")
ErrInvalidDefault is the sentinel for any canonicalization failure.
var ErrUnsupportedDataType = errors.New("unsupported dataType")
ErrUnsupportedDataType is returned by Resolve and Typed when given a DataType not in the canonical enum.
Functions ¶
func CanonicalizeMap ¶ added in v0.4.1
func CanonicalizeMap(raw json.RawMessage) (map[string]string, error)
CanonicalizeMap decodes raw as map[string]string. Null values and non-string values are rejected.
func CanonicalizeScalar ¶ added in v0.4.1
func CanonicalizeScalar(raw json.RawMessage, dataType DataType) (string, error)
CanonicalizeScalar returns the canonical Valkey string form of raw as dataType. Non-scalar dataType returns an error.
func CanonicalizeSet ¶ added in v0.4.1
func CanonicalizeSet(raw json.RawMessage) ([]string, error)
CanonicalizeSet decodes raw as []string. Null elements and non-string elements are rejected.
Types ¶
type DataType ¶ added in v0.4.1
type DataType string
DataType is the canonical set of variable data types recognized across MDAI components (operator CRD, gateway, event-hub, data-core). The literal string values match the kubebuilder enum on MdaiHub's VariableDataType field and are the wire format used in event payloads and audit entries.
const ( DataTypeInt DataType = "int" // signed integer, stored as a string in Valkey DataTypeFloat DataType = "float" // 64-bit float, stored as a string in Valkey; writers must canonicalize via strconv.FormatFloat(v, 'g', -1, 64) DataTypeBoolean DataType = "boolean" // "true" or "false" as a string in Valkey DataTypeString DataType = "string" DataTypeSet DataType = "set" // Valkey SET DataTypeMap DataType = "map" // Valkey HASH; field-value pairs are strings DataTypeMetaHashSet DataType = "metaHashSet" // module-backed lookup table (input key → value via a referenced set) DataTypeMetaPriorityList DataType = "metaPriorityList" // module-backed ordered references; evaluates to the first non-empty )
type OperationArgs ¶
type Reader ¶ added in v0.4.1
type Reader interface {
GetString(ctx context.Context, variableKey, hubName string) (string, bool, error)
GetSetAsStringSlice(ctx context.Context, variableKey, hubName string) ([]string, error)
GetMap(ctx context.Context, variableKey, hubName string) (map[string]string, error)
GetMetaPriorityList(ctx context.Context, variableKey, hubName string) ([]string, bool, error)
GetMetaHashSet(ctx context.Context, variableKey, hubName string) (string, bool, error)
}
Reader is the read interface Resolve depends on; ValkeyAdapter satisfies it.
type ResolveResult ¶ added in v0.4.1
ResolveResult is the outcome of a variable read. Value is the canonical form (string for scalars, []string for sets, map[string]string for maps). IsDefault distinguishes a materialized default from a stored value.
func Resolve ¶ added in v0.4.1
func Resolve( ctx context.Context, adapter Reader, hubName, varKey string, dataType DataType, defaultRaw json.RawMessage, ) (ResolveResult, error)
Resolve reads the variable; on not-found it materializes defaultRaw via the canonicalizers. defaultRaw==nil means no default declared. For set/map, a zero-length read is treated as not-found.
func (ResolveResult) Typed ¶ added in v0.4.1
func (r ResolveResult) Typed() (any, error)
Typed returns Value as int64, float64, bool, string, []string, or map[string]string per the originating dataType.
type ValkeyAdapter ¶
type ValkeyAdapter struct {
// contains filtered or unexported fields
}
func NewValkeyAdapter ¶
func NewValkeyAdapter(client valkey.Client, logger *zap.Logger, opts ...ValkeyAdapterOption) *ValkeyAdapter
func (*ValkeyAdapter) AddElementToSet ¶
func (*ValkeyAdapter) AuditStreamExpiry ¶
func (r *ValkeyAdapter) AuditStreamExpiry() time.Duration
func (*ValkeyAdapter) BulkSetMap ¶
func (*ValkeyAdapter) DeleteKeysWithPrefixUsingScan ¶
func (*ValkeyAdapter) DeleteString ¶
func (r *ValkeyAdapter) DeleteString(variableKey string, hubName string) valkey.Completed
func (*ValkeyAdapter) GetMapAsString ¶
func (*ValkeyAdapter) GetMetaHashSet ¶ added in v0.3.1
func (*ValkeyAdapter) GetMetaPriorityList ¶ added in v0.3.1
func (*ValkeyAdapter) GetOrCreateMetaHashSet ¶
func (*ValkeyAdapter) GetOrCreateMetaPriorityList ¶
func (*ValkeyAdapter) GetSetAsStringSlice ¶
func (*ValkeyAdapter) GetString ¶
func (r *ValkeyAdapter) GetString(ctx context.Context, variableKey string, hubName string) (string, bool, error)
GetString retrieves the string, int and boolean variable. It returns the value, a boolean indicating whether the key was found, and any error encountered.
func (*ValkeyAdapter) RemoveElementFromSet ¶
func (*ValkeyAdapter) RemoveMapEntry ¶
func (*ValkeyAdapter) SetMapEntry ¶
type ValkeyAdapterOption ¶
type ValkeyAdapterOption func(*ValkeyAdapter)
func WithValkeyAuditStreamExpiry ¶
func WithValkeyAuditStreamExpiry(expiry time.Duration) ValkeyAdapterOption