c3dfc9315f
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>
1.8 KiB
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. |
|
|
false |
|
|
DagDefinition con todos los campos normalizados; error si el YAML es sintaticamente invalido | true |
|
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.