Skip to main content

open_from_env

Function open_from_env 

Source
pub fn open_from_env(
    root: &Path,
    account: &str,
    hash: GitHashKind,
) -> Result<SelectedStore>
Expand description

The env-driven front door: read the three variables once, here, and build the store they name.

This is the whole runtime selector a server or a bench needs — one call, one triple of getenvs, and from then on the store holds built objects and reads nothing. There is deliberately no per-operation lookup of any kind: a std::env::var inside a serving loop would be one syscall per object served, which is a real defect that was found and fixed in gunnar the day before this was written. crate::arms::env_reads counts every read this crate makes so that “once, at construction” is an assertion rather than a claim.

An unset variable takes the shipping default, so a process with a clean environment gets exactly GitStore::open’s combination.