Documentation ¶
Index ¶
- func BoolFromValue(v kv.Value, key string, defaultValue bool, opts Options) (bool, error)
- func Float64FromValue(v kv.Value, key string, defaultValue float64, opts Options) (float64, error)
- func Int64FromValue(v kv.Value, key string, defaultValue int64, opts Options) (int64, error)
- func StringArrayFromValue(v kv.Value, key string, defaultValue []string, opts Options) ([]string, error)
- func StringFromValue(v kv.Value, key string, defaultValue string, opts Options) (string, error)
- func TimeFromValue(v kv.Value, key string, defaultValue time.Time, opts Options) (time.Time, error)
- func WatchAndUpdateAtomicBool(store kv.Store, key string, property *atomic.Bool, defaultValue bool, ...) (kv.ValueWatch, error)
- func WatchAndUpdateAtomicFloat64(store kv.Store, key string, property *atomic.Float64, defaultValue float64, ...) (kv.ValueWatch, error)
- func WatchAndUpdateAtomicInt64(store kv.Store, key string, property *atomic.Int64, defaultValue int64, ...) (kv.ValueWatch, error)
- func WatchAndUpdateAtomicString(store kv.Store, key string, property *atomic.String, defaultValue string, ...) (kv.ValueWatch, error)
- func WatchAndUpdateBool(store kv.Store, key string, property *bool, lock sync.Locker, ...) (kv.ValueWatch, error)
- func WatchAndUpdateFloat64(store kv.Store, key string, property *float64, lock sync.Locker, ...) (kv.ValueWatch, error)
- func WatchAndUpdateInt64(store kv.Store, key string, property *int64, lock sync.Locker, ...) (kv.ValueWatch, error)
- func WatchAndUpdateString(store kv.Store, key string, property *string, lock sync.Locker, ...) (kv.ValueWatch, error)
- func WatchAndUpdateStringArray(store kv.Store, key string, property *[]string, lock sync.Locker, ...) (kv.ValueWatch, error)
- func WatchAndUpdateStringArrayPointer(store kv.Store, key string, property **[]string, lock sync.Locker, ...) (kv.ValueWatch, error)
- func WatchAndUpdateTime(store kv.Store, key string, property *time.Time, lock sync.Locker, ...) (kv.ValueWatch, error)
- type Options
- type ValidateFn
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BoolFromValue ¶
BoolFromValue get a bool from kv.Value. If the value is nil, the default value is returned.
func Float64FromValue ¶
Float64FromValue gets a float64 from kv.Value. If the value is nil, the default value is returned.
func Int64FromValue ¶
Int64FromValue gets an int64 from kv.Value. If the value is nil, the default value is returned.
func StringArrayFromValue ¶
func StringArrayFromValue( v kv.Value, key string, defaultValue []string, opts Options, ) ([]string, error)
StringArrayFromValue gets a string array from kv.Value. If the value is nil, the default value is returned.
func StringFromValue ¶
StringFromValue gets a string from kv.Value. If the value is nil, the default value is returned.
func TimeFromValue ¶
func TimeFromValue( v kv.Value, key string, defaultValue time.Time, opts Options, ) (time.Time, error)
TimeFromValue gets a time.Time from kv.Value. If the value is nil, the default value is returned.
func WatchAndUpdateAtomicBool ¶
func WatchAndUpdateAtomicBool( store kv.Store, key string, property *atomic.Bool, defaultValue bool, opts Options, ) (kv.ValueWatch, error)
WatchAndUpdateAtomicBool sets up a watch with validation for an atomic bool property. Any malformed or invalid updates are not applied. The default value is applied when the key does not exist in KV. The watch on the value is returned.
func WatchAndUpdateAtomicFloat64 ¶
func WatchAndUpdateAtomicFloat64( store kv.Store, key string, property *atomic.Float64, defaultValue float64, opts Options, ) (kv.ValueWatch, error)
WatchAndUpdateAtomicFloat64 sets up a watch with validation for an atomic float64 property. Any malformed or invalid updates are not applied. The default value is applied when the key does not exist in KV. The watch on the value is returned.
func WatchAndUpdateAtomicInt64 ¶
func WatchAndUpdateAtomicInt64( store kv.Store, key string, property *atomic.Int64, defaultValue int64, opts Options, ) (kv.ValueWatch, error)
WatchAndUpdateAtomicInt64 sets up a watch with validation for an atomic int64 property. Anymalformed or invalid updates are not applied. The default value is applied when the key does not exist in KV. The watch on the value is returned.
func WatchAndUpdateAtomicString ¶
func WatchAndUpdateAtomicString( store kv.Store, key string, property *atomic.String, defaultValue string, opts Options, ) (kv.ValueWatch, error)
WatchAndUpdateAtomicString sets up a watch with validation for an atomic string property. Any malformed or invalid updates are not applied. The default value is applied when the key does not exist in KV. The watch on the value is returned.
func WatchAndUpdateBool ¶
func WatchAndUpdateBool( store kv.Store, key string, property *bool, lock sync.Locker, defaultValue bool, opts Options, ) (kv.ValueWatch, error)
WatchAndUpdateBool sets up a watch with validation for a bool property. Any malformed or invalid updates are not applied. The default value is applied when the key does not exist in KV. The watch on the value is returned.
func WatchAndUpdateFloat64 ¶
func WatchAndUpdateFloat64( store kv.Store, key string, property *float64, lock sync.Locker, defaultValue float64, opts Options, ) (kv.ValueWatch, error)
WatchAndUpdateFloat64 sets up a watch with validation for a float64 property. Any malformed or invalid updates are not applied. The default value is applied when the key does not exist in KV. The watch on the value is returned.
func WatchAndUpdateInt64 ¶
func WatchAndUpdateInt64( store kv.Store, key string, property *int64, lock sync.Locker, defaultValue int64, opts Options, ) (kv.ValueWatch, error)
WatchAndUpdateInt64 sets up a watch with validation for an int64 property. Any malformed or invalid updates are not applied. The default value is applied when the key does not exist in KV. The watch on the value is returned.
func WatchAndUpdateString ¶
func WatchAndUpdateString( store kv.Store, key string, property *string, lock sync.Locker, defaultValue string, opts Options, ) (kv.ValueWatch, error)
WatchAndUpdateString sets up a watch with validation for a string property. Any malformed or invalid updates are not applied. The default value is applied when the key does not exist in KV. The watch on the value is returned.
func WatchAndUpdateStringArray ¶
func WatchAndUpdateStringArray( store kv.Store, key string, property *[]string, lock sync.Locker, defaultValue []string, opts Options, ) (kv.ValueWatch, error)
WatchAndUpdateStringArray sets up a watch with validation for a string array property. Any malformed, or invalid updates are not applied. The default value is applied when the key does not exist in KV. The watch on the value is returned.
func WatchAndUpdateStringArrayPointer ¶
func WatchAndUpdateStringArrayPointer( store kv.Store, key string, property **[]string, lock sync.Locker, defaultValue *[]string, opts Options, ) (kv.ValueWatch, error)
WatchAndUpdateStringArrayPointer sets up a watch with validation for a string array pointer property. Any malformed, or invalid updates are not applied. The default value is applied when the key does not exist in KV. The watch on the value is returned.
func WatchAndUpdateTime ¶
func WatchAndUpdateTime( store kv.Store, key string, property *time.Time, lock sync.Locker, defaultValue time.Time, opts Options, ) (kv.ValueWatch, error)
WatchAndUpdateTime sets up a watch with validation for a time property. Any malformed, or invalid updates are not applied. The default value is applied when the key does not exist in KV. The watch on the value is returned.
Types ¶
type Options ¶
type Options interface { // SetValidateFn sets the validation function applied to kv values. SetValidateFn(val ValidateFn) Options // ValidateFn returns the validation function applied to kv values. ValidateFn() ValidateFn // SetLogger sets the logger. SetLogger(val log.Logger) Options // Logger returns the logger. Logger() log.Logger }
Options is a set of options for kv utility functions.
func NewOptions ¶
func NewOptions() Options
NewOptions returns a new set of options for kv utility functions.