You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

55 lines
924 B

8 years ago
  1. package main
  2. import (
  3. "bufio"
  4. "fmt"
  5. "log"
  6. "github.com/tendermint/tendermint/abci/types"
  7. cmn "github.com/tendermint/tendermint/libs/common"
  8. )
  9. func main() {
  10. conn, err := cmn.Connect("unix://test.sock")
  11. if err != nil {
  12. log.Fatal(err.Error())
  13. }
  14. // Read a bunch of responses
  15. go func() {
  16. counter := 0
  17. for {
  18. var res = &types.Response{}
  19. err := types.ReadMessage(conn, res)
  20. if err != nil {
  21. log.Fatal(err.Error())
  22. }
  23. counter++
  24. if counter%1000 == 0 {
  25. fmt.Println("Read", counter)
  26. }
  27. }
  28. }()
  29. // Write a bunch of requests
  30. counter := 0
  31. for i := 0; ; i++ {
  32. var bufWriter = bufio.NewWriter(conn)
  33. var req = types.ToRequestEcho("foobar")
  34. err := types.WriteMessage(req, bufWriter)
  35. if err != nil {
  36. log.Fatal(err.Error())
  37. }
  38. err = bufWriter.Flush()
  39. if err != nil {
  40. log.Fatal(err.Error())
  41. }
  42. counter++
  43. if counter%1000 == 0 {
  44. fmt.Println("Write", counter)
  45. }
  46. }
  47. }