Example #1
0
func main() {

	flag.Parse()

	nodnodClient := client.NewClient(*flServer)

	if err := nodnodClient.Connect(); err != nil {
		log.Fatal("Failed to connect", err)
	}

	defer nodnodClient.Disconnect()

	count := 0

	for {
		if allStats, err := nodnodClient.StatAll(); err != nil {
			log.Error("Failed to get stats:", err)
		} else {
			prettyPrint(allStats)
		}

		count++
		if *flCount > 0 && count >= *flCount {
			log.Info("Reached maximum number of requests: ", count)
			nodnodClient.Disconnect()
			fmt.Println("Disconnected client.\nBye!")
			return
		}

		time.Sleep(5 * time.Second)
	}
}
Example #2
0
func newNode(address string) *Node {
	return &Node{
		address: address,
		client:  client.NewClient(address),
	}
}