Skip to main content

DescriptorExt

Trait DescriptorExt 

Source
pub trait DescriptorExt {
    // Required methods
    fn resolve_aliases_and_set_defaults(
        &self,
    ) -> Result<BTreeMap<NodeId, ResolvedNode>>;
    fn visualize_as_mermaid_with_boundaries(
        &self,
        boundaries: &ModuleBoundaries,
    ) -> Result<String>;
    fn apply_exit_when_nodes_finish(&mut self, over: Option<bool>);
    fn blocking_read(path: &Path) -> Result<Descriptor>;
    fn parse(buf: Vec<u8>) -> Result<Descriptor>;
    fn check(&self, working_dir: &Path) -> Result<()>;
    fn expand(&self, working_dir: &Path) -> Result<Descriptor>;
    fn expand_with_boundaries(
        &self,
        working_dir: &Path,
    ) -> Result<(Descriptor, ModuleBoundaries)>;
}
Expand description

Operations on a parsed Descriptor.

These live on an extension trait rather than inherent methods because Descriptor is defined in dora-message (the wire-format crate), while the parsing, validation, resolution, and visualization logic belongs to dora-core. Import the trait to turn a descriptor into the resolved node map dora runs, validate it, or render it as a mermaid graph.

§Example

use dora_core::descriptor::{Descriptor, DescriptorExt};

let yaml = b"
nodes:
  - id: source
    path: ./source
    outputs: [data]
  - id: sink
    path: ./sink
    inputs:
      value: source/data
";

// Parse the YAML into a descriptor...
let descriptor = Descriptor::parse(yaml.to_vec())?;
assert_eq!(descriptor.nodes.len(), 2);

// ...then resolve aliases and fill in defaults to get the node map dora runs.
let resolved = descriptor.resolve_aliases_and_set_defaults()?;
assert_eq!(resolved.len(), 2);

Required Methods§

Source

fn resolve_aliases_and_set_defaults( &self, ) -> Result<BTreeMap<NodeId, ResolvedNode>>

Resolve the descriptor into the map of nodes dora runs.

Fills in defaults, rewrites single-operator input references to the operator-qualified output name, and returns the nodes keyed by id. The descriptor must already be module-expanded (see expand) if it contains module: references.

Source

fn visualize_as_mermaid_with_boundaries( &self, boundaries: &ModuleBoundaries, ) -> Result<String>

Render the resolved dataflow as a mermaid flowchart, annotated with the given module boundaries (from expand_with_boundaries).

Source

fn apply_exit_when_nodes_finish(&mut self, over: Option<bool>)

Apply a command-line override to the dataflow’s completion policy.

None leaves the descriptor’s own exit_when_nodes_finish alone, so a setting written in the YAML stands; Some(v) overrides it in either direction, so --exit-when-nodes-finish can force the policy on and =false can force it off for a descriptor that asks for it (dora-rs/dora#2920).

Shared rather than spelled out at each call site: dora run, dora start and the daemon all have to agree, and three copies of the same three lines is how one of them ends up not being updated.

Source

fn blocking_read(path: &Path) -> Result<Descriptor>

Read a descriptor from a YAML file at path and parse it.

Source

fn parse(buf: Vec<u8>) -> Result<Descriptor>

Parse a descriptor from raw YAML bytes.

This only deserializes; it does not expand modules or validate the dataflow — use check for that.

Source

fn check(&self, working_dir: &Path) -> Result<()>

Expand modules and validate the whole dataflow (node ids, input wiring, field combinations, …), resolving relative paths against working_dir.

Source

fn expand(&self, working_dir: &Path) -> Result<Descriptor>

Expand all module references into flat nodes.

Module nodes are replaced by the inner nodes defined in their module file. Internal IDs are prefixed with {module_id}. and input/output wiring is rewritten accordingly.

Source

fn expand_with_boundaries( &self, working_dir: &Path, ) -> Result<(Descriptor, ModuleBoundaries)>

Like expand but also returns module boundary metadata for visualization.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§