feat(health): add TCP connectivity probe

This commit is contained in:
ahp
2026-10-15 14:29:19 +03:30
parent 465c482854
commit 3e7ec7f44f
2 changed files with 66 additions and 0 deletions
+21
View File
@@ -0,0 +1,21 @@
// SPDX-License-Identifier: MIT
// Package health performs post-apply connectivity checks.
package health
import (
"context"
"fmt"
"net"
"time"
)
// DialTCP attempts a TCP connection to addr within timeout.
func DialTCP(ctx context.Context, addr string, timeout time.Duration) error {
d := net.Dialer{Timeout: timeout}
conn, err := d.DialContext(ctx, "tcp", addr)
if err != nil {
return fmt.Errorf("connect %s: %w", addr, err)
}
return conn.Close()
}