Files
fn_registry/functions/infra/cron_ticker.md
T
egutierrez 988e901066 docs: params/output semántico en 506 funciones para composabilidad
Añade campos params y output al frontmatter YAML de las 506 funciones del registry.
Cada parámetro tiene descripción semántica (qué representa, unidades, rango típico)
y cada función describe qué produce su output. Permite a agentes razonar sobre
cadenas de composición (ej: prices → log_return → sharpe_ratio) sin leer código.
2026-04-05 18:45:16 +02:00

1.9 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
cron_ticker function go infra 1.0.0 impure func CronTicker(schedule CronTickerSchedule, ctx context.Context) <-chan time.Time Crea un channel que emite time.Time en cada tick del cron schedule. Usa time.NewTimer internamente, recalculando el proximo tick tras cada emision. El channel se cierra al cancelar el context. Incluye CronTickerSchedule (reflejo local de CronSchedule para evitar dependencia cross-package).
cron
scheduling
ticker
channel
goroutine
concurrency
impure
parse_cron_expr_go_core
next_cron_time_go_core
cron_schedule_go_core
false error_go_core
context
time
name desc
schedule estructura CronTickerSchedule con campos Minute, Hour, DayOfMonth, Month, DayOfWeek
name desc
ctx context que al cancelarse cierra el channel de ticks
channel que emite time.Time en cada tick del schedule cron true
context cancel cierra el channel
ticker emite al llegar el momento del schedule
functions/infra/cron_ticker_test.go functions/infra/cron_ticker.go

Ejemplo

sched := CronTickerSchedule{
    Minute:     []int{0, 15, 30, 45},
    Hour:       intRange(0, 23),
    DayOfMonth: intRange(1, 31),
    Month:      intRange(1, 12),
    DayOfWeek:  intRange(0, 6),
}
ctx, cancel := context.WithCancel(context.Background())
defer cancel()

for tick := range CronTicker(sched, ctx) {
    fmt.Println("tick:", tick)
}

Notas

Funcion impura: lanza una goroutine, usa time.NewTimer y context. El tipo CronTickerSchedule es un reflejo local de core.CronSchedule para evitar imports cross-package entre dominios Go. En uso real, convertir el resultado de core.ParseCronExpr manualmente. El channel tiene buffer de 1 para evitar bloqueos si el consumidor es lento; los ticks extras se descartan.