mirror of
https://github.com/dagucloud/dagu.git
synced 2026-12-05 21:34:48 +00:00
37 lines
1.1 KiB
Go
37 lines
1.1 KiB
Go
// Copyright (C) 2026 Yota Hamada
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
// Package dispatch holds control-plane policy for deciding how a DAG run is
|
|
// executed. It is platform code: it combines language-level DAG fields with
|
|
// runtime configuration to choose between local and coordinator-dispatched
|
|
// execution.
|
|
package dispatch
|
|
|
|
import (
|
|
"errors"
|
|
|
|
"github.com/dagucloud/dagu/v2/internal/cmn/config"
|
|
"github.com/dagucloud/dagu/v2/internal/ir"
|
|
)
|
|
|
|
// ErrBuildRequiresLocal reports that distributed materialization fencing is unavailable.
|
|
var ErrBuildRequiresLocal = errors.New("build workflows require local execution; distributed fencing is not implemented")
|
|
|
|
// ShouldDispatchToCoordinator decides whether a DAG should be dispatched
|
|
// to the coordinator for distributed execution.
|
|
func ShouldDispatchToCoordinator(dag *ir.DAG, hasCoordinator bool, defaultMode config.ExecutionMode) bool {
|
|
if dag.ForceLocal {
|
|
return false
|
|
}
|
|
if !hasCoordinator {
|
|
return false
|
|
}
|
|
if len(dag.WorkerSelector) > 0 {
|
|
return true
|
|
}
|
|
if defaultMode == config.ExecutionModeDistributed {
|
|
return true
|
|
}
|
|
return false
|
|
}
|