1// 2// Freelance client - Model 3. 3// Uses flcliapi class to encapsulate Freelance pattern 4// 5 6package main 7 8import ( 9 "github.com/pebbe/zmq4/examples/flcliapi" 10 11 "fmt" 12 "time" 13) 14 15func main() { 16 // Create new freelance client object 17 client := flcliapi.New() 18 19 // Connect to several endpoints 20 client.Connect("tcp://localhost:5555") 21 client.Connect("tcp://localhost:5556") 22 client.Connect("tcp://localhost:5557") 23 24 // Send a bunch of name resolution 'requests', measure time 25 start := time.Now() 26 req := []string{"random name"} 27 for requests := 1000; requests > 0; requests-- { 28 _, err := client.Request(req) 29 if err != nil { 30 fmt.Println("E: name service not available, aborting") 31 break 32 } 33 } 34 fmt.Println("Average round trip cost:", time.Now().Sub(start)/1000) 35} 36