示例#1
0
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()
}
示例#2
0
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
}
示例#3
0
文件: server.go 项目: shaladdle/goaaw
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
}
示例#4
0
文件: server.go 项目: shaladdle/goaaw
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
}