-
Notifications
You must be signed in to change notification settings - Fork 103
/
ping.go
38 lines (30 loc) · 824 Bytes
/
ping.go
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
28
29
30
31
32
33
34
35
36
37
38
package runtime
import (
"fmt"
"github.com/rilldata/rill/cli/pkg/cmdutil"
runtimev1 "github.com/rilldata/rill/proto/gen/rill/runtime/v1"
"github.com/rilldata/rill/runtime/client"
"github.com/spf13/cobra"
)
func PingCmd(ch *cmdutil.Helper) *cobra.Command {
var runtimeURL string
pingCmd := &cobra.Command{
Use: "ping",
Short: "Ping",
RunE: func(cmd *cobra.Command, args []string) error {
client, err := client.New(runtimeURL, "")
if err != nil {
return err
}
defer client.Close()
pong, err := client.Ping(cmd.Context(), &runtimev1.PingRequest{})
if err != nil {
return err
}
fmt.Printf("Pong: %s\n", pong.Time.AsTime().String())
return nil
},
}
pingCmd.Flags().StringVar(&runtimeURL, "url", "http://localhost:49009", "Base URL for the runtime")
return pingCmd
}