示例#1
0
文件: node.go 项目: tanxunrong/mixer
func (n *Node) openDB(addr string) (*client.DB, error) {
	db, err := client.Open(addr, n.cfg.User, n.cfg.Password, "")
	if err != nil {
		return nil, err
	}

	db.SetIdleConns(n.cfg.IdleConns)
	return db, nil
}
示例#2
0
func newTestDB(t *testing.T) *client.DB {
	newTestServer(t)

	f := func() {
		var err error
		testDB, err = client.Open("127.0.0.1:4000", "root", "", "mixer")

		if err != nil {
			t.Fatal(err)
		}

		testDB.SetIdleConns(4)
	}

	testDBOnce.Do(f)
	return testDB
}