Expand description
Thread-safe runtime environment — replaces std::env::set_var.
Thread-safe runtime environment for API keys and config.
Replaces unsafe { std::env::set_var() } with a concurrent map
that is safe to read/write from any tokio task.
Read priority: runtime map → process environment.
§Why not std::env::set_var?
set_var is unsafe in multi-threaded programs (undefined behavior in
Rust 2024 edition). Since Koda uses tokio with multiple tasks (main
REPL, background agents, version checker), we need a thread-safe
alternative.
Functions§
- get
- Get a runtime variable, falling back to
std::env::var. Checks our runtime map first, then the real process environment. - is_set
- Check if a runtime variable is set (in either runtime map or process env).
- remove
- Remove a key from the runtime map (does not touch process env).
- set
- Set a runtime environment variable (thread-safe).