()
| 14 | } |
| 15 | |
| 16 | func main() { |
| 17 | // Create a kite |
| 18 | k := kite.New("exp2", "1.0.0") |
| 19 | |
| 20 | // Create mathworker client |
| 21 | mathWorker := k.NewClient("http://localhost:3636/kite") |
| 22 | |
| 23 | // Connect to remote kite |
| 24 | connected, err := mathWorker.DialForever() |
| 25 | if err != nil { |
| 26 | k.Log.Fatal(err.Error()) |
| 27 | } |
| 28 | |
| 29 | // Wait until connected |
| 30 | <-connected |
| 31 | |
| 32 | // Call square method every second |
| 33 | for range time.Tick(time.Second) { |
| 34 | i := rand.Intn(10) |
| 35 | |
| 36 | // Call a method of mathworker kite |
| 37 | response, err := mathWorker.TellWithTimeout("square", 4*time.Second, &math.Request{ |
| 38 | Number: i, |
| 39 | Name: "example-2-kite", |
| 40 | }) |
| 41 | if err != nil { |
| 42 | k.Log.Error(err.Error()) |
| 43 | continue |
| 44 | } |
| 45 | |
| 46 | // Print the result |
| 47 | result := response.MustFloat64() |
| 48 | fmt.Printf("input: %d result: %.0f\n", i, result) |
| 49 | } |
| 50 | } |
nothing calls this directly
no test coverage detected