-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmain.go
72 lines (58 loc) · 1.42 KB
/
main.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package main
import (
"fmt"
"github.com/rluisr/mysqlrouter-go"
)
func main() {
mr, err := mysqlrouter.New("http://localhost:8080", "root", "mysql", nil)
if err != nil {
panic(err)
}
routes, err := mr.GetAllRoutes()
if err != nil {
panic(err)
}
route := routes[1].Name
fmt.Printf("route name: %s\n", route)
routeStatus, err := mr.GetRouteStatus(route)
if err != nil {
panic(err)
}
fmt.Printf("route status: %+v\n", routeStatus)
routeHealth, err := mr.GetRouteHealth(route)
if err != nil {
panic(err)
}
fmt.Printf("route health: %+v\n", routeHealth)
routeDestinations, err := mr.GetRouteDestinations(route)
if err != nil {
panic(err)
}
fmt.Printf("route destinations: %+v\n", routeDestinations[0])
routeConnections, err := mr.GetRouteConnections(route)
if err != nil {
panic(err)
}
fmt.Printf("route connections: %+v\n", routeConnections)
metadatas, err := mr.GetAllMetadata()
if err != nil {
panic(err)
}
metadata := metadatas[0].Name
fmt.Printf("metadata name: %s\n", metadata)
metadataConfig, err := mr.GetMetadataConfig(metadata)
if err != nil {
panic(err)
}
fmt.Printf("metadata config: %+v\n", metadataConfig)
metadataStatus, err := mr.GetMetadataStatus(metadata)
if err != nil {
panic(err)
}
fmt.Printf("metadata status: %+v\n", metadataStatus)
routerStatus, err := mr.GetRouterStatus()
if err != nil {
panic(err)
}
fmt.Printf("router status: %+v\n", routerStatus)
}