blob: 10550d7dcea44c462f298ea9c91c2d4e2fb58891 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
package rubyserver
import (
"time"
"golang.org/x/net/context"
"google.golang.org/grpc"
healthpb "google.golang.org/grpc/health/grpc_health_v1"
)
func ping(address string) error {
conn, err := grpc.Dial(
address,
grpc.WithInsecure(),
)
if err != nil {
return err
}
defer conn.Close()
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second)
defer cancel()
client := healthpb.NewHealthClient(conn)
_, err = client.Check(ctx, &healthpb.HealthCheckRequest{})
return err
}
|