add timeout to tcp checker

Signed-off-by: Christian Richter <crichter@owncloud.com>
This commit is contained in:
Christian Richter
2024-10-14 08:22:47 +02:00
parent 941e688ae6
commit 6064386787

View File

@@ -3,12 +3,13 @@ package handlers
import (
"context"
"net"
"time"
)
// NewTCPCheck returns a check that connects to a given tcp endpoint.
func NewTCPCheck(address string) func(ctx context.Context) error {
return func(_ context.Context) error {
conn, err := net.Dial("tcp", address)
conn, err := net.DialTimeout("tcp", address, 3*time.Second)
if err != nil {
return err
}