5f4f1f7508
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.
45 lines
1.6 KiB
Markdown
45 lines
1.6 KiB
Markdown
---
|
|
name: health_check_http
|
|
kind: function
|
|
lang: go
|
|
domain: infra
|
|
version: "1.0.0"
|
|
purity: impure
|
|
signature: "func HealthCheckHTTP(url string, timeoutSecs, intervalMs int) error"
|
|
description: "Hace polling HTTP GET a un endpoint hasta recibir status 200 o hasta agotar el timeout. Útil para esperar que un servicio levante antes de continuar un pipeline."
|
|
tags: [http, health, check, polling, wait, infra]
|
|
uses_functions: []
|
|
uses_types: []
|
|
returns: []
|
|
returns_optional: false
|
|
error_type: "error_go_core"
|
|
imports: [fmt, net/http, time]
|
|
params:
|
|
- name: url
|
|
desc: "URL del endpoint HTTP a verificar (GET)"
|
|
- name: timeoutSecs
|
|
desc: "tiempo maximo en segundos antes de agotar los intentos"
|
|
- name: intervalMs
|
|
desc: "intervalo en milisegundos entre intentos de verificacion"
|
|
output: "nil si el endpoint responde 200, error si se agota el timeout"
|
|
tested: true
|
|
tests: ["retorna nil cuando el servidor responde 200", "retorna error si el timeout se agota", "respeta el intervalo entre intentos"]
|
|
test_file_path: "functions/infra/health_check_http_test.go"
|
|
file_path: "functions/infra/health_check_http.go"
|
|
---
|
|
|
|
## Ejemplo
|
|
|
|
```go
|
|
// Esperar hasta 60s a que Metabase levante, polling cada 2s
|
|
err := HealthCheckHTTP("http://localhost:3000/api/health", 60, 2000)
|
|
if err != nil {
|
|
log.Fatal("Servicio no disponible:", err)
|
|
}
|
|
fmt.Println("Servicio listo")
|
|
```
|
|
|
|
## Notas
|
|
|
|
Usa solo net/http de la stdlib, sin dependencias externas. El cliente HTTP tiene timeout de intervalMs + 500ms para no bloquear el loop. Retorna el ultimo error si el timeout expira. No sigue redirects especiales — cualquier respuesta 200 OK es exito.
|