Skip to main content

run

Function run 

Source
pub async fn run(
    workspace: Option<PathBuf>,
    format: AnalyzeFormat,
    threshold_vacuum: f64,
    threshold_partition_rows: i64,
) -> Result<(), AnalyzeError>
Expand description

djogi analyze entry point — consumed by main.rs::TopCommand::Analyze. Orchestrates the live-DB pull, the pure recommendation pass, and the rendering. Splitting fetch / recommend / render this way means every test (unit, integration, regression) targets exactly the layer that interests it without dragging in the others.

§Workspace + config resolution

workspace is None by default — we resolve to std::env::current_dir() and then load Djogi.toml via DjogiConfig::load_from_workspace. Mirrors verify::run’s pattern.

§Pool lifecycle

One pool, one context, every per-table query runs through it. Built fresh on every invocation — analyze is a one-shot CLI command, not a long-lived process, so pool reuse across invocations is not a goal.

§Output destination

Both rendering paths write to a locked stdout. Locking once at the top means we don’t pay the Stdout::lock() cost per row, and the renderers themselves take a generic &mut W: Write so the pure render-only tests (render_human_* / render_json_*) can target a Vec<u8> without going through stdout.