Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
01-07-2020 05:45 AM
Hi,
I'm testing https://github.com/mindstand/golang-neo4j-bolt-driver with connection pooling.
I do this:
func Test_BoltDriverPool_Concurrent(t *testing.T) {
neo4jConnStr := os.Getenv("NEO4J_BOLT")
if neo4jConnStr != "" {
t.Log("Using NEO4J for tests:", neo4jConnStr)
}
pool, err := boltDriver.NewDriverPool(neo4jConnStr, 5)
if err != nil {
t.Fatalf("An error occurred opening driver pool: %#v", err)
}
var countGoroutine int32 = 0
var wg sync.WaitGroup
for i := 0; i < 5; i++ { // OK i <= pool size
// for i := 0; i < 10; i++ { // KO i > pool size, does not end
wg.Add(1)
go func() {
defer wg.Done()
conn, err := pool.Open(0)
if err != nil {
t.Fatalf("An error occurred opening conn from pool: %#v", err)
}
defer conn.Close()
minSec := 2
maxSec := 5
waitSec := rand.Intn(maxSec-minSec) + minSec
atomic.AddInt32(&countGoroutine, 1)
t.Logf("%d - Waiting %d s.", countGoroutine, waitSec)
time.Sleep(time.Second * time.Duration(waitSec))
}()
time.Sleep(time.Millisecond * time.Duration(100))
}
wg.Wait()
}
I don't understand how pooling works.
Indeed if i < 5 (pool size) I get display, on the other hand, it does not end without display information or error.
All the sessions of the conference are now available online