dynconfig

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package dynconfig provides dynamic configuration with atomic reads.

DynConfig allows runtime updates to configuration values without restarts. Reads are lock-free (~1.8 ns) using atomic.Value, making it suitable for hot-path configuration such as rate limits and feature flags.

Example:

cfg := dynconfig.New(initialConfig)
current := cfg.Get() // atomic read, ~1.8 ns
cfg.Set(newConfig)   // atomic write with change notification

Package dynconfig provides dynamic configuration for GRIP execution pipelines.

Value[T] is the fundamental building block: it holds any configuration value (e.g., supervisor policy, admission limit) that can be swapped atomically at runtime without restarting the service.

Usage:

// Create a dynamic admission limit
limit := dynconfig.NewValue(100)

// Read the current value (lock-free)
current := limit.Get()

// Update at runtime (atomic swap)
limit.Set(200)

// Listen for changes
limit.OnChange(func(old, new int) {
    log.Printf("admission limit changed: %d → %d", old, new)
})

Snapshot provides a registry for debugging active configuration:

snap := dynconfig.NewSnapshot()
snap.Register("admission_limit", func() any { return limit.Get() })
fmt.Println(snap.Capture()) // {"admission_limit": 200}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Snapshot

type Snapshot = idc.Snapshot

Snapshot captures the current state of all registered dynamic values.

func NewSnapshot

func NewSnapshot() *Snapshot

NewSnapshot creates a new configuration snapshot for debugging.

type Value

type Value[T any] = idc.Value[T]

Value holds a configuration value that can be swapped atomically at runtime.

Thread-safe: reads are lock-free (atomic.Value), writes use sync.Mutex.

func NewValue

func NewValue[T any](initial T) *Value[T]

NewValue creates a new dynamic configuration value.

limit := dynconfig.NewValue(100)          // int
policy := dynconfig.NewValue(myPolicy)    // SupervisorPolicy
timeout := dynconfig.NewValue(5*time.Second) // time.Duration

Jump to

Keyboard shortcuts

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