Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable the load extension API #39

Merged
merged 14 commits into from
Aug 25, 2018
Prev Previous commit
Next Next commit
rm Pool.All()
  • Loading branch information
ksshannon committed Aug 21, 2018
commit cc10f3acfae63ea32006f83df414deacb514fd5d
20 changes: 0 additions & 20 deletions pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,26 +145,6 @@ func (p *Pool) Close() (err error) {
return err
}

// All attempts to call function f on each conn in the pool, stopping if doneCh
// is sent on. The number of connections visited and the first error
// enctountered from f is returned.
func (p *Pool) All(f func(conn *Conn) error, doneCh <-chan struct{}) (int, error) {
n := 0
for n < len(p.all) {
conn := p.Get(doneCh)
if conn == nil {
return n, nil
}
defer p.Put(conn)
err := f(conn)
if err != nil {
return n, err
}
n++
}
return n, nil
}

type strerror struct {
msg string
}
Expand Down
43 changes: 0 additions & 43 deletions pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,46 +126,3 @@ func TestPoolAfterClose(t *testing.T) {
}
}
}

func TestPoolAll(t *testing.T) {
const sz = 24
p, err := sqlite.Open("", 0, sz)
if err != nil {
t.Fatal(err)
}
n, err := p.All(func(conn *sqlite.Conn) error { return nil }, nil)
if err != nil {
t.Error("failed to touch all connections: %s", err)
}
if n != sz {
t.Error("failed to touch all connections, got %d, want %d", n, sz)
}

n, err = p.All(func(conn *sqlite.Conn) error {
_, err := conn.Prepare("BAD SQL")
if err != nil {
return err
}
return nil
}, nil)
if err == nil {
t.Error("bad", n)
}
if n > 0 {
t.Error("failed to touch all connections, got %d, want %d", n, sz)
}

done := make(chan struct{}, 2)
done <- struct{}{}

n, err = p.All(func(conn *sqlite.Conn) error {
return nil
}, done)
if err != nil {
t.Error("failed to touch all connections: %s", err)
}
if n >= sz {
t.Error("failed to touch all connections, got %d, want %d", n, sz)
}

}