MCPcopy Create free account
hub / github.com/koding/kite / main

Function main

examples/exp2-query/exp2-query.go:18–59  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

16}
17
18func main() {
19 // Create a kite
20 k := kite.New("exp2", "1.0.0")
21 k.Config = config.MustGet()
22
23 kites, err := k.GetKites(&protocol.KontrolQuery{
24 Username: k.Config.Username,
25 Environment: k.Config.Environment,
26 Name: "math",
27 })
28 if err != nil {
29 log.Fatalln(err)
30 }
31
32 // Connect to remote kite
33 defer kite.Close(kites[1:])
34
35 mathWorker := kites[0]
36 connected, err := mathWorker.DialForever()
37 if err != nil {
38 k.Log.Fatal(err.Error())
39 }
40
41 // Wait until connected
42 <-connected
43
44 // Call square method every second
45 for range time.Tick(time.Second) {
46 i := rand.Intn(10)
47
48 // Call a method of mathworker kite
49 response, err := mathWorker.TellWithTimeout("square", 4*time.Second, i)
50 if err != nil {
51 k.Log.Error(err.Error())
52 continue
53 }
54
55 // Print the result
56 result := response.MustFloat64()
57 fmt.Printf("input: %d result: %.0f\n", i, result)
58 }
59}

Callers

nothing calls this directly

Calls 7

GetKitesMethod · 0.80
DialForeverMethod · 0.80
FatalMethod · 0.80
TellWithTimeoutMethod · 0.80
MustFloat64Method · 0.80
ErrorMethod · 0.65
CloseMethod · 0.45

Tested by

no test coverage detected