Skip to main content

resolve_cluster_dispatch

Function resolve_cluster_dispatch 

Source
pub fn resolve_cluster_dispatch(chain: &[Option<bool>]) -> bool
Expand description

Resolve whether a leaf command should fan out across the cluster, given the chain of super::schema::CommandSpec::cluster directives along its command path, ordered root → leaf.

Walks the chain from leaf back to root; the first Some value wins. This makes deeper overrides take precedence:

  • root sets cluster: true, leaf unset → true (inherits)
  • root sets cluster: true, leaf sets cluster: falsefalse (override)
  • root unset, leaf sets cluster: truetrue
  • all unset → false (no clustering by default)

Intended caller pattern (from a future dispatch in run.rs):

let chain: Vec<Option<bool>> = ancestors.iter()
    .map(|spec| spec.cluster)
    .collect();
if cluster_dispatch_enabled(&project, &chain) {
    // fan out across project.cluster.workers
}

This is a pure function on the chain; cluster-block presence is checked separately by cluster_dispatch_enabled.