mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-01-08 21:30:07 -06:00
add timeout to tcp checker
Signed-off-by: Christian Richter <crichter@owncloud.com>
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user