fix govpp, add more checks to makefile
[govpp.git] / examples / simple-client / simple_client.go
index 08d4da6..a494e81 100644 (file)
@@ -25,6 +25,7 @@ import (
 
        "git.fd.io/govpp.git"
        "git.fd.io/govpp.git/api"
+       "git.fd.io/govpp.git/core"
        "git.fd.io/govpp.git/examples/bin_api/acl"
        "git.fd.io/govpp.git/examples/bin_api/interfaces"
        "git.fd.io/govpp.git/examples/bin_api/ip"
@@ -34,12 +35,19 @@ func main() {
        fmt.Println("Starting simple VPP client...")
 
        // connect to VPP
-       conn, err := govpp.Connect("")
+       conn, conev, err := govpp.AsyncConnect("", core.DefaultMaxReconnectAttempts, core.DefaultReconnectInterval)
        if err != nil {
                log.Fatalln("ERROR:", err)
        }
        defer conn.Disconnect()
 
+       select {
+       case e := <-conev:
+               if e.State != core.Connected {
+                       log.Fatalf("failed to connect: %v", e.Error)
+               }
+       }
+
        // create an API channel that will be used in the examples
        ch, err := conn.NewAPIChannel()
        if err != nil {