How schell/moongraph works
Project Type and Purpose
• Project Type: A Rust library (monorepo) consisting of three interrelated crates for building and scheduling directed acyclic graphs (DAGs).
• Purpose:
• Expose a procedural‐macro API so users write normal Rust functions as graph nodes.
• Automatically construct the DAG by inspecting function inputs/outputs.
• Schedule and run the graph, using the dagga scheduler and broomdog resource manager.
• Optionally parallelize execution with Rayon.
File Structure
• Top‐level:
• Cargo.toml, rustfmt.toml, README.md, .github workflows (CI).
• crates/ directory: three crates:
1. moongraph-macros-syntax (procedural‐macro syntax parsing)
2. moongraph-macros (user‐facing derive macros & glue to core)
3. moongraph (core library: DAG builder, scheduler integration, runtime modules)
• Inside core:
• src/lib.rs – high-level API and registration logic
• rayon_impl.rs – parallel execution implementation behind the “parallel” feature
• tutorial_impl.rs – example/tutorial code paths
• CI: GitHub Actions for building/testing on each push.
README for Additional Insights
• Two main sub‐systems:
• Scheduler: dagga (external)
• Resource manager: broomdog (external)
• Features:
• “parallel” → turns on Rayon for concurrent node execution.
• Usage: crates are intended to be consumed by other Rust projects (renderling, apecs, etc.).
Main Components and Their Relationships
1. moongraph-macros-syntax
2. moongraph-macros
3. moongraph (core library)
4. External dependencies: dagga (scheduler), broomdog (resource manager), rayon (optional parallel engine)
5. CI Workflow (GitHub Actions) – optional, shows build/test pipeline
b. Interactions:
• macros-syntax → produces parsing helpers consumed by macros
• macros → emit registration code that calls into moongraph core API
• moongraph core → builds DAG, invokes dagga & broomdog, optionally rayon_impl
• dagga & broomdog → plugged into core for scheduling & resource management
• rayon_impl (feature gate “parallel”) → provides parallel executor backend to core
c. Architectural Patterns
• Procedural‐macro pipeline: syntax‐crate → macro‐crate → core library
• Plugin‐style dependency injection: external scheduler/resource manager behind traits
• Feature‐flag toggle for parallel execution
d. Key Technologies
• Rust procedural macros (proc_macro)
• dagga (DAG scheduler)
• broomdog (resource manager)
• rayon (thread‐parallelism)
• GitHub Actions (CI)