flowlog-build 0.2.1

Build-time FlowLog compiler for library mode.
Documentation

Status: FlowLog is under active development; interfaces may change without notice.


flowlog-build compiles a Datalog (.dl) program into a Rust module your crate include!s from build.rs. It pairs with flowlog-runtime, which supplies the dataflow primitives the generated code depends on.

If you want a standalone Datalog-to-Rust CLI instead of a build-script integration, see the flowlog-compiler binary in the FlowLog repo.

Setup

# Cargo.toml
[dependencies]
flowlog-runtime = "0.2"

[build-dependencies]
flowlog-build = "0.2"
// build.rs
fn main() -> std::io::Result<()> {
    flowlog_build::compile("policy.dl")
}
// src/lib.rs
pub mod policy {
    include!(concat!(env!("OUT_DIR"), "/policy.rs"));
}

use policy::DatalogBatchEngine;

let mut engine = DatalogBatchEngine::new(4); // 4 timely workers
engine.insert_edge(vec![(1, 2), (2, 3)]);
let results = engine.run();

The generated module exposes one insert_<relation> method per input relation declared in the .dl program, plus a run() that returns all output relations.

Advanced Options

Use Builder when you need multiple programs, include directories, UDFs, or non-default codegen flags:

use flowlog_build::Builder;

// build.rs
fn main() {
    if let Err(err) = Builder::default()
        .sip(true)              // sideways information passing
        .string_intern(true)    // intern string-typed columns at ingest
        .udf_file("src/udf.rs") // included as `mod udf` in generated code
        .compile(
            &["policy.dl", "auth.dl"],
            &["shared/includes"],
        )
    {
        eprintln!("{err}");
        std::process::exit(1);
    }
}

See the API docs for the full Builder surface.

Error Rendering

The free compile() function renders any pipeline diagnostic against the source map and surfaces it through io::Error, so cargo build shows a source-annotated error. Builder::compile returns the structured BoxError instead if you want to format it yourself.

License

Apache-2.0 — see LICENSE.