forked from fagongzi/manba
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cluster.go
52 lines (41 loc) · 817 Bytes
/
cluster.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
47
48
49
50
51
52
package main
import (
"fmt"
"github.com/fagongzi/gateway/pkg/pb/metapb"
)
func createCluster() error {
c, err := getClient()
if err != nil {
return err
}
id, err := c.NewClusterBuilder().Name("cluster-01").Loadbalance(metapb.RoundRobin).Commit()
if err != nil {
return err
}
fmt.Printf("cluster id is: %d", id)
return nil
}
func deleteCluster(id uint64) error {
c, err := getClient()
if err != nil {
return err
}
return c.RemoveCluster(id)
}
func updateCluster(id uint64) error {
c, err := getClient()
if err != nil {
return err
}
cluster, err := c.GetCluster(id)
if err != nil {
return err
}
// 修改名称
_, err = c.NewClusterBuilder().Use(*cluster).Name("cluster-1").Commit()
if err != nil {
return err
}
fmt.Printf("cluster %d name is updated", id)
return nil
}