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.

54 lines
913 B

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