func (cli *grpcClient) EchoAsync(msg string) *ReqRes { req := types.ToRequestEcho(msg) res, err := cli.client.Echo(context.Background(), req.GetEcho(), grpc.FailFast(true)) if err != nil { cli.StopForError(err) } return cli.finishAsyncCall(req, &types.Response{&types.Response_Echo{res}}) }
func (cli *socketClient) EchoSync(msg string) (res types.Result) { reqres := cli.queueRequest(types.ToRequestEcho(msg)) cli.FlushSync() if err := cli.Error(); err != nil { return types.ErrInternalError.SetLog(err.Error()) } resp := reqres.Response.GetEcho() return types.Result{Code: OK, Data: []byte(resp.Message), Log: LOG} }
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.ToRequestEcho("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) } } }
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.ToRequestEcho("foobar") _, err := makeRequest(conn, req) if err != nil { Exit(err.Error()) } counter += 1 if counter%1000 == 0 { fmt.Println(counter) } } }
func (cli *socketClient) EchoAsync(msg string) *ReqRes { return cli.queueRequest(types.ToRequestEcho(msg)) }
func (app *localClient) EchoAsync(msg string) *ReqRes { return app.callback( types.ToRequestEcho(msg), types.ToResponseEcho(msg), ) }