/
cmd.service.go
46 lines (42 loc) · 996 Bytes
/
cmd.service.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
39
40
41
42
43
44
45
46
package tarus_app
import (
"context"
"fmt"
"github.com/Myriad-Dreamin/tarus/api/tarus"
"github.com/k0kubun/pp/v3"
"github.com/urfave/cli"
)
var commandService = Command{
Name: "service",
Usage: "service operations",
Action: actServiceStatus,
Subcommands: []cli.Command{
{
Name: "status",
Usage: "check service status",
Action: actServiceStatus,
},
},
}.WithInitService()
func actServiceStatus(c *Client, args *cli.Context) error {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
resp, err := c.grpcClient.Handshake(ctx, &tarus.HandshakeRequest{
ApiVersion: []byte(args.App.Version),
})
if err != nil {
return err
}
type ServiceStatus struct {
ApiVersion string
JudgeStatusHash string
ImplementedApis []string
}
fmt.Printf("Response: ")
_, err = pp.Println(ServiceStatus{
ApiVersion: string(resp.ApiVersion),
JudgeStatusHash: resp.JudgeStatusHash,
ImplementedApis: resp.ImplementedApis,
})
return err
}