Beispiel #1
0
func generator(first, second float64, tick <-chan time.Time, e *G.Gilmour) {
	//Wait for a tick
	<-tick

	packet := map[string]float64{"first": first, "second": second}
	data := G.NewMessage().SetData(packet)

	req := e.NewRequest(fibTopic)
	resp, err := req.Execute(data)
	if err != nil {
		fmt.Println("Error in Handler", err)
		return
	}

	if resp.Code() != 200 {
		fmt.Println("Error in Handler", resp.Code())
		return
	}

	var next float64
	msg := resp.Next()
	if err := msg.GetData(&next); err != nil {
		fmt.Println(err)
		return
	}

	generator(second, next, tick, e)
}
Beispiel #2
0
func echoRequest(wg *sync.WaitGroup, engine *G.Gilmour, msg string) {
	req := engine.NewRequest("echo")
	resp, err := req.Execute(G.NewMessage().SetData(msg))
	if err != nil {
		fmt.Println("Echoclient: error", err.Error())
	}

	defer wg.Done()

	var output string
	if err := resp.Next().GetData(&output); err != nil {
		fmt.Println("Echoclient: error", err.Error())
	} else {
		fmt.Println("Echoclient: received", output)
	}
}