Documentation
¶
Index ¶
- func NewAtomicBool[C any](config Observable[C], accessor func(*C) bool) *atomic.Bool
- func NewAtomicDuration[C any](config Observable[C], accessor func(*C) time.Duration) *atomic.Duration
- func NewAtomicFloat32[C any](config Observable[C], accessor func(*C) float32) *atomic.Float32
- func NewAtomicFloat64[C any](config Observable[C], accessor func(*C) float64) *atomic.Float64
- func NewAtomicInt32[C any](config Observable[C], accessor func(*C) int32) *atomic.Int32
- func NewAtomicInt64[C any](config Observable[C], accessor func(*C) int64) *atomic.Int64
- func NewAtomicPointer[T, C any](config Observable[C], accessor func(*C) *T) *atomic.Pointer[T]
- func NewAtomicString[C any](config Observable[C], accessor func(*C) string) *atomic.String
- func NewAtomicTime[C any](config Observable[C], accessor func(*C) time.Time) *atomic.Time
- func NewAtomicUint32[C any](config Observable[C], accessor func(*C) uint32) *atomic.Uint32
- func NewAtomicUint64[C any](config Observable[C], accessor func(*C) uint64) *atomic.Uint64
- type AtomicValue
- type Builder
- type ConfigObserver
- type Defaulter
- type Observable
- type Observer
- type Validator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewAtomicBool ¶
func NewAtomicBool[C any](config Observable[C], accessor func(*C) bool) *atomic.Bool
func NewAtomicDuration ¶
func NewAtomicFloat32 ¶
func NewAtomicFloat32[C any](config Observable[C], accessor func(*C) float32) *atomic.Float32
func NewAtomicFloat64 ¶
func NewAtomicFloat64[C any](config Observable[C], accessor func(*C) float64) *atomic.Float64
func NewAtomicInt32 ¶
func NewAtomicInt32[C any](config Observable[C], accessor func(*C) int32) *atomic.Int32
func NewAtomicInt64 ¶
func NewAtomicInt64[C any](config Observable[C], accessor func(*C) int64) *atomic.Int64
func NewAtomicPointer ¶
func NewAtomicPointer[T, C any](config Observable[C], accessor func(*C) *T) *atomic.Pointer[T]
func NewAtomicString ¶
func NewAtomicString[C any](config Observable[C], accessor func(*C) string) *atomic.String
func NewAtomicTime ¶
func NewAtomicUint32 ¶
func NewAtomicUint32[C any](config Observable[C], accessor func(*C) uint32) *atomic.Uint32
func NewAtomicUint64 ¶
func NewAtomicUint64[C any](config Observable[C], accessor func(*C) uint64) *atomic.Uint64
Types ¶
type AtomicValue ¶
type AtomicValue[T any] struct { // contains filtered or unexported fields }
func NewAtomicValue ¶
func NewAtomicValue[T, C any](config Observable[C], accessor func(*C) T) *AtomicValue[T]
func (*AtomicValue[T]) Load ¶
func (a *AtomicValue[T]) Load() T
func (*AtomicValue[T]) Store ¶
func (a *AtomicValue[T]) Store(v T)
type ConfigObserver ¶
type ConfigObserver[T any] = Observable[T]
type Observable ¶ added in v1.51.0
type Observable[T any] interface { Observe(cb func(*T)) func() Load() *T }
func Derive ¶ added in v1.52.1
func Derive[Src, Dst any](src Observable[Src], project func(*Src) *Dst) Observable[Dst]
Derive narrows an observable onto a subtree of itself, so a package can define the config it owns, have the app embed it, and observe just that subtree without importing the app's config package.
project selects; it must not compute. It runs on every Load, so it has to be cheap, and it must return a pointer into its argument rather than a freshly built value — callers (NewAtomicPointer among them) compare what Load returns by identity. For a projection that has to build something, use the NewAtomic* helpers instead: they cache the result and recompute it on reload.
The result holds no state and needs no cleanup: it subscribes to src only while something is subscribed to it, and forwards src's emit semantics unchanged.
type Observer ¶ added in v1.51.0
type Observer[T any] struct { // contains filtered or unexported fields }
func NewObserver ¶ added in v1.51.0
func NewStaticObserver ¶ added in v1.52.1
NewStaticObserver stubs observable config in tests, and backs dev paths that must hand back the same *Observer the production path does.
The nil builder is safe only because load is unreachable without a watcher.
func (*Observer[T]) EmitConfigUpdate ¶ added in v1.51.0
func (c *Observer[T]) EmitConfigUpdate(conf *T)