-
Notifications
You must be signed in to change notification settings - Fork 62
/
main.go
51 lines (40 loc) · 862 Bytes
/
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
package main
import (
"log"
"github.com/bluenviron/goroslib/v2"
)
func main() {
// create a node and connect to the master
n, err := goroslib.NewNode(goroslib.NodeConf{
Name: "goroslib_info",
MasterAddress: "127.0.0.1:11311",
})
if err != nil {
panic(err)
}
defer n.Close()
// get all nodes linked to master
nodes, err := n.MasterGetNodes()
if err != nil {
panic(err)
}
log.Println("nodes:", nodes)
// get all machines that are hosting nodes linked to master
machines, err := n.MasterGetMachines()
if err != nil {
panic(err)
}
log.Println("machines:", machines)
// get all topics
topics, err := n.MasterGetTopics()
if err != nil {
panic(err)
}
log.Println("topics:", topics)
// get all services
services, err := n.MasterGetServices()
if err != nil {
panic(err)
}
log.Println("services:", services)
}