You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jul 22, 2018. It is now read-only.
If many goroutines access the pool, more connections are created than expected, perhaps you can devise a way to only create the connection when the send is clear.
func TestCreations(t *testing.T) {
var m sync.Mutex
var connectionCount int
p, _ := NewChannelPool(InitialCap, MaximumCap, func() (net.Conn, error) {
m.Lock()
defer m.Unlock()
connectionCount++
return net.Dial(network, address)
})
defer p.Close()
var wg sync.WaitGroup
numWorkers := MaximumCap * 2
wg.Add(numWorkers)
for i := 0; i < numWorkers; i++ {
go func() {
_, err := p.Get()
if err != nil {
t.Fatal(err)
}
// c.Close()
wg.Done()
}()
}
wg.Wait()
if connectionCount != MaximumCap {
t.Errorf("expected connection count %d, got %d", MaximumCap, connectionCount)
}
}
$ go test -run=Creations -race
--- FAIL: TestCreations (0.04s)
channel_test.go:76: expected connection count 30, got 60
FAIL
The text was updated successfully, but these errors were encountered:
I'm archiving and closing this project. It's not going to be maintained anymore. Thanks all for their valuable feedback and contributions. If you have questions, feel free to reach me from https://twitter.com/fatih
If many goroutines access the pool, more connections are created than expected, perhaps you can devise a way to only create the connection when the send is clear.
The text was updated successfully, but these errors were encountered: