Files
fn_registry/functions/infra/health_check_http.md
T
egutierrez 1d45f232c6 feat: funciones infra — Docker, deploy, build y health check
Funciones impuras para gestión de contenedores: docker_build_image,
docker_compose_up/down, docker_volume_create/list/remove,
generate_dockerfile, write_dockerfile, go_build_binary, health_check_http,
deploy_app y stop_app. Todas con tests unitarios donde aplica.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-30 14:24:12 +02:00

1.3 KiB

name, kind, lang, domain, version, purity, signature, description, tags, uses_functions, uses_types, returns, returns_optional, error_type, imports, 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 tested tests test_file_path file_path
health_check_http function go infra 1.0.0 impure func HealthCheckHTTP(url string, timeoutSecs, intervalMs int) error 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.
http
health
check
polling
wait
infra
false error_go_core
fmt
net/http
time
true
retorna nil cuando el servidor responde 200
retorna error si el timeout se agota
respeta el intervalo entre intentos
functions/infra/health_check_http_test.go functions/infra/health_check_http.go

Ejemplo

// 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.