Ejemplo n.º 1
0
func (app *localAppConn) EchoAsync(msg string) *tmspcli.ReqRes {
	app.Callback(
		tmsp.RequestEcho(msg),
		tmsp.ResponseEcho(msg),
	)
	return nil // TODO maybe create a ReqRes
}
Ejemplo n.º 2
0
// Have the application echo a message
func cmdEcho(c *cli.Context) {
	args := c.Args()
	if len(args) != 1 {
		fmt.Println("echo takes 1 argument")
		return
	}
	res, err := makeRequest(conn, types.RequestEcho(args[0]))
	if err != nil {
		fmt.Println(err.Error())
		return
	}
	printResponse(res, string(res.Data))
}
Ejemplo n.º 3
0
func main() {

	conn, err := Connect("unix://test.sock")
	if err != nil {
		Exit(err.Error())
	}

	// Read a bunch of responses
	go func() {
		counter := 0
		for {
			var res = &types.Response{}
			err := types.ReadMessage(conn, res)
			if err != nil {
				Exit(err.Error())
			}
			counter += 1
			if counter%1000 == 0 {
				fmt.Println("Read", counter)
			}
		}
	}()

	// Write a bunch of requests
	counter := 0
	for i := 0; ; i++ {
		var bufWriter = bufio.NewWriter(conn)
		var req = types.RequestEcho("foobar")

		err := types.WriteMessage(req, bufWriter)
		if err != nil {
			Exit(err.Error())
		}
		err = bufWriter.Flush()
		if err != nil {
			Exit(err.Error())
		}

		counter += 1
		if counter%1000 == 0 {
			fmt.Println("Write", counter)
		}
	}
}
Ejemplo n.º 4
0
func main() {

	conn, err := Connect("unix://test.sock")
	if err != nil {
		Exit(err.Error())
	}

	// Make a bunch of requests
	counter := 0
	for i := 0; ; i++ {
		req := types.RequestEcho("foobar")
		_, err := makeRequest(conn, req)
		if err != nil {
			Exit(err.Error())
		}
		counter += 1
		if counter%1000 == 0 {
			fmt.Println(counter)
		}
	}
}
Ejemplo n.º 5
0
func (cli *TMSPClient) EchoAsync(msg string) *ReqRes {
	return cli.queueRequest(types.RequestEcho(msg))
}