Files
fn_registry/functions/core/dag_parse.md
T
egutierrez 3136eb862f feat: add DAG core functions — parse, validate, topo sort, resolve env, cron match (0007a, 0007d)
Pure functions for parsing dagu-compatible YAML, validating DAG structure,
topological sorting with parallel levels (Kahn's algorithm), and env variable
resolution. Also adds cron_match for schedule matching.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-12 13:05:05 +02:00

1.8 KiB

name, kind, lang, domain, version, purity, signature, description, tags, uses_functions, uses_types, returns, returns_optional, error_type, imports, params, output, tested, tests, test_file_path, file_path
name kind lang domain version purity signature description tags uses_functions uses_types returns returns_optional error_type imports params output tested tests test_file_path file_path
dag_parse function go core 1.0.0 pure func DagParse(data []byte) (DagDefinition, error) Parsea YAML de definicion de DAG en formato compatible con Dagu. Soporta schedule como string o lista, env como lista de maps single-key (formato Dagu), handler_on y handlers como aliases, steps con command/script/depends/continue_on, y type graph.
dag
yaml
parsing
workflow
dagu
pure
dag_definition_go_core
dag_step_go_core
dag_handlers_go_core
false
fmt
strings
gopkg.in/yaml.v3
name desc
data contenido YAML de un archivo de definicion de DAG en formato Dagu
DagDefinition con todos los campos normalizados; error si el YAML es sintaticamente invalido true
parsea DAG simple con steps y depends
parsea schedule como string y como lista
parsea env en formato lista de maps
parsea handler_on y handlers como alias
parsea continue_on y working_dir a nivel step
parsea type graph
functions/core/dag_parse_test.go functions/core/dag_parse.go

Ejemplo

data := []byte(`
name: mi-dag
schedule: "0 9 * * *"
steps:
  - name: hello
    command: echo "hello"
  - name: world
    command: echo "world"
    depends: [hello]
`)
dag, err := DagParse(data)
// dag.Name = "mi-dag"
// dag.Schedule = ["0 9 * * *"]
// dag.Steps[1].Depends = ["hello"]

Notas

Funcion pura (el YAML es inmutable, no hay I/O). Internamente usa un struct rawDag para deserializar loosely y luego normaliza campos polimorficos. La estrategia de normalizacion: schedule string->[]string, env lista->map, handlers single-o-lista->[]DagStep. handler_on tiene precedencia sobre handlers si ambos estan presentes.