diff --git a/.vscode/launch.json b/.vscode/launch.json index c23774c..69a3a34 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -9,7 +9,7 @@ "type": "go", "request": "launch", "mode": "auto", - "program": "${fileDirname}", + "program":"${workspaceFolder}/test/test.go", "env": {}, "args": [] } diff --git a/client/client.go b/client/client.go index bbf0b2e..1070dcd 100755 --- a/client/client.go +++ b/client/client.go @@ -7,7 +7,7 @@ import ( "fmt" "strconv" - "github.com/seefan/gossdb/ssdbclient" + "github.com/seefan/gossdb/v2/ssdbclient" ) const ( diff --git a/client/close.go b/client/close.go index ec348b6..1aa0904 100644 --- a/client/close.go +++ b/client/close.go @@ -1,6 +1,7 @@ package client + //Close 可关闭接口 -type Close interface{ +type Close interface { //CloseBack close func CloseBack() -} \ No newline at end of file +} diff --git a/go.mod b/go.mod index 7c5021a..5db2f99 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/seefan/gossdb +module github.com/seefan/gossdb/v2 go 1.14 diff --git a/gossdb.go b/gossdb.go index f63b420..68f0072 100644 --- a/gossdb.go +++ b/gossdb.go @@ -3,8 +3,8 @@ package gossdb import ( "errors" - "github.com/seefan/gossdb/conf" - "github.com/seefan/gossdb/pool" + "github.com/seefan/gossdb/v2/conf" + "github.com/seefan/gossdb/v2/pool" ) var ( diff --git a/pool/connectors.go b/pool/connectors.go index 2eb7bcc..6f5194e 100644 --- a/pool/connectors.go +++ b/pool/connectors.go @@ -10,10 +10,10 @@ import ( "sync/atomic" "time" - "github.com/seefan/gossdb/client" - "github.com/seefan/gossdb/conf" - "github.com/seefan/gossdb/consts" - "github.com/seefan/gossdb/ssdbclient" + "github.com/seefan/gossdb/v2/client" + "github.com/seefan/gossdb/v2/conf" + "github.com/seefan/gossdb/v2/consts" + "github.com/seefan/gossdb/v2/ssdbclient" ) //Connectors connection pool @@ -171,7 +171,7 @@ func (c *Connectors) appendPool() (err error) { p.index = pos atomic.AddInt32(&c.cellPos, 1) } - println("append pool", pos+1) + //println("append pool", pos+1) return nil } diff --git a/pool/connectors_test.go b/pool/connectors_test.go index 3b2825a..a0b8a2b 100644 --- a/pool/connectors_test.go +++ b/pool/connectors_test.go @@ -4,7 +4,7 @@ import ( "sync" "testing" - "github.com/seefan/gossdb/conf" + "github.com/seefan/gossdb/v2/conf" ) func BenchmarkConnectors_NewClient10(b *testing.B) { diff --git a/pool/pool.go b/pool/pool.go index 7733a08..1fde422 100644 --- a/pool/pool.go +++ b/pool/pool.go @@ -3,8 +3,8 @@ package pool import ( "sync" - "github.com/seefan/gossdb/consts" - "github.com/seefan/gossdb/queue" + "github.com/seefan/gossdb/v2/consts" + "github.com/seefan/gossdb/v2/queue" ) //Pool pool block diff --git a/pool/pool_client.go b/pool/pool_client.go index 21bd06f..af16ca2 100644 --- a/pool/pool_client.go +++ b/pool/pool_client.go @@ -1,7 +1,7 @@ package pool import ( - "github.com/seefan/gossdb/client" + "github.com/seefan/gossdb/v2/client" ) //Client pooled client diff --git a/ssdbclient/ssdb_client.go b/ssdbclient/ssdb_client.go index c95f146..d336bdc 100644 --- a/ssdbclient/ssdb_client.go +++ b/ssdbclient/ssdb_client.go @@ -13,7 +13,7 @@ import ( "time" "github.com/seefan/goerr" - "github.com/seefan/gossdb/conf" + "github.com/seefan/gossdb/v2/conf" ) const ( diff --git a/ssdbclient/ssdb_client_test.go b/ssdbclient/ssdb_client_test.go index 3fd99bc..6abf974 100644 --- a/ssdbclient/ssdb_client_test.go +++ b/ssdbclient/ssdb_client_test.go @@ -5,7 +5,7 @@ import ( "testing" "time" - "github.com/seefan/gossdb/conf" + "github.com/seefan/gossdb/v2/conf" ) func TestSSDBClient_ping(t *testing.T) { @@ -244,11 +244,11 @@ func TestSSDBClient_getBig(t *testing.T) { // t.Error(err) //} //for i := 0; i < 1000; i++ { - if v, err := c.Do("hget", "app:0","1359003378"); err == nil { - t.Log(len(v[1])) - } else { - t.Error(err) - } + if v, err := c.Do("hget", "app:0", "1359003378"); err == nil { + t.Log(len(v[1])) + } else { + t.Error(err) + } //} if err := c.Close(); err != nil { t.Fatal(err) @@ -287,7 +287,7 @@ func TestSSDBClient_multiget(t *testing.T) { t.Fatal(err) } defer c.Close() - if v, err := c.Do("multi_hget", "black:0", "0:0:1000565011","0:0:1001394200"); err == nil { + if v, err := c.Do("multi_hget", "black:0", "0:0:1000565011", "0:0:1001394200"); err == nil { t.Log(v) } else { t.Error(err) diff --git a/test/test.go b/test/test.go index 0e0e9fa..a086912 100644 --- a/test/test.go +++ b/test/test.go @@ -7,14 +7,13 @@ package main import ( - "log" "math" _ "net/http/pprof" "sync" "time" - "github.com/seefan/gossdb" - "github.com/seefan/gossdb/conf" + "github.com/seefan/gossdb/v2" + "github.com/seefan/gossdb/v2/conf" ) func main() { @@ -24,10 +23,10 @@ func main() { MaxWaitSize: 10000, PoolSize: 5, MinPoolSize: 5, - MaxPoolSize: 50, + MaxPoolSize: 10, AutoClose: true, //Password: "vdsfsfafapaddssrd#@Ddfasfdsfedssdfsdfsd", - HealthSecond: 5, + HealthSecond: 10, }) if err != nil { panic(err) @@ -41,20 +40,20 @@ func main() { // }() var wait sync.WaitGroup - for i := 0; i < 100; i++ { + for i := 0; i < 7; i++ { wait.Add(1) go func() { for k := 0; k < 100; k++ { - for j := 0; j < 100; j++ { - e := p.GetClient().Set("big", "ddddd") - if e == nil { - if _, e := p.GetClient().Get("big"); err != nil { - log.Println(e) - } + c, e := p.NewClient() + + if e != nil { + println(e.Error()) + } else { + time.Sleep(time.Millisecond * time.Duration(math.Round(10))) + c.Close() } } - time.Sleep(time.Millisecond * time.Duration(math.Round(100))) //println(p.Info()) } wait.Done()