package com.correx.core.config

import java.util.concurrent.atomic.AtomicReference

/**
 * Live, swappable [CorrexConfig]. Services that consult [get] at use-time pick up edits applied
 * via [set] without a restart. Config is not event-sourced — it lives in TOML — so this holder
 * is the single in-memory authority for the running server's current configuration.
 */
class ConfigHolder(initial: CorrexConfig) {
    private val ref = AtomicReference(initial)

    fun get(): CorrexConfig = ref.get()

    fun set(cfg: CorrexConfig) {
        ref.set(cfg)
    }
}
