This guide walks you through running your first Lattice graph in about ten minutes.
- JDK 21 (matching the project's Gradle toolchain).
- The checked-in Gradle wrapper (
./gradlew/gradlew.bat). - Optional: Rust 1.85+ + Cargo, only if you want the native placement backend for Linux affinity and NUMA diagnostics.
./gradlew test
./gradlew jmhClasses examplesClassesThe portable release gate is:
./gradlew releaseCheckThis compiles main, examples, tests, JMH, JCStress; builds the runtime jar, sources jar, and javadoc jar; generates the Maven POM; and verifies the documentation links you are reading right now. It also generates a CycloneDX SBOM and enforces the current JaCoCo coverage floor: at least 80% line and 65% branch coverage on the release scope.
The Maven Central coordinate is:
implementation("io.github.elevateddev:lattice:1.0.0")import io.github.elevateddev.lattice.edge.EdgeSpec;
import io.github.elevateddev.lattice.graph.SourceMode;
import io.github.elevateddev.lattice.graph.StaticGraph;
import io.github.elevateddev.lattice.stage.Emitter;
import io.github.elevateddev.lattice.stage.StageSpec;
import java.time.Duration;
record Order(int id, boolean valid) {}
record ValidOrder(int id) {}
StaticGraph graph = StaticGraph.builder("orders")
.source("ingress", Order.class, SourceMode.SINGLE_PRODUCER)
.stage("validate", Order.class, ValidOrder.class,
(order, out, ctx) -> { if (order.valid()) out.push(new ValidOrder(order.id())); },
StageSpec.singleThreaded())
.sink("egress", ValidOrder.class, order -> { /* persist */ }, StageSpec.singleThreaded())
.edge("ingress", "validate", EdgeSpec.spscRing(1024))
.edge("validate", "egress", EdgeSpec.spscRing(1024))
.build();
graph.start();
Emitter<Order> ingress = graph.emitter("ingress", Order.class);
ingress.emit(new Order(1, true));
ingress.close();
graph.awaitTermination(Duration.ofSeconds(5));SourceMode.SINGLE_PRODUCER is a correctness contract: at most one
application thread may call the emitter at a time. Use the default source mode
and an MPSC ingress edge when producers are concurrent.
- Graph DSL - every builder method.
- Edge Semantics - SPSC vs MPSC, capacity rules, slab handles.
- Ordering Guarantees - exactly what Lattice promises.
- Backpressure - overflow policies, sizing, redirect.
- Observability - metrics, JFR events, placement reports.
- Architecture - how Lattice compiles your graph.
- Examples Overview - runnable, JMH-grade examples.