MCPcopy Index your code
hub / github.com/koding/kite / main

Function main

examples/exp2/exp2.go:16–50  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

14}
15
16func 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}

Callers

nothing calls this directly

Calls 6

DialForeverMethod · 0.95
TellWithTimeoutMethod · 0.95
NewClientMethod · 0.80
FatalMethod · 0.80
MustFloat64Method · 0.80
ErrorMethod · 0.65

Tested by

no test coverage detected