func BenchmarkPipeClientCreate(b *testing.B) { pnet := anet.NewPipeNet() srv := NewServer() defer srv.Close() go srv.Accept(pnet) b.ResetTimer() for i := 0; i < b.N; i++ { NewClient(pnet) } b.StopTimer() }
func newTestCliSrv(t *testing.T, s interface{}) (*Client, *Server) { pnet := anet.NewPipeNet() rpcs := NewServer() rpcs.Register(serverPrefix, s) go rpcs.Accept(pnet) cli, err := NewClient(pnet) if err != nil { t.Errorf("client creation failed: %v", err) } return cli, rpcs }
func NewPipeCliSrv(regName string, o interface{}) (*Client, *Server, error) { pnet := anet.NewPipeNet() srv := NewServer() srv.Register(regName, o) go srv.Accept(pnet) cli, err := NewClient(pnet) if err != nil { srv.Close() return nil, nil, err } return cli, srv, nil }
func NewPipeCliSrv(root string) (*Client, *Server, error) { pnet := anet.NewPipeNet() srv, err := NewServer(root, pnet) if err != nil { return nil, nil, err } cli, err := NewClient(pnet) if err != nil { srv.Close() return nil, nil, err } return cli, srv, nil }