sqlite storage: Init schema in NewPool instead of NewProvider and add an option to disable
This commit is contained in:
parent
d04622e4b3
commit
784345e9f7
|
@ -154,6 +154,7 @@ type NewPoolOpts struct {
|
|||
NumConns int
|
||||
// Forces WAL, disables shared caching.
|
||||
ConcurrentBlobReads bool
|
||||
DontInitSchema bool
|
||||
}
|
||||
|
||||
// There's some overlap here with NewPoolOpts, and I haven't decided what needs to be done. For now,
|
||||
|
@ -190,6 +191,14 @@ func NewPool(opts NewPoolOpts) (_ ConnPool, _ ProviderOpts, err error) {
|
|||
if err != nil {
|
||||
return
|
||||
}
|
||||
if !opts.DontInitSchema {
|
||||
conn := conns.Get(context.TODO())
|
||||
defer conns.Put(conn)
|
||||
err = initSchema(conn)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
return conns, ProviderOpts{
|
||||
NumConns: opts.NumConns,
|
||||
ConcurrentBlobRead: opts.ConcurrentBlobReads,
|
||||
|
@ -226,12 +235,6 @@ func NewProvider(pool ConnPool, opts ProviderOpts) (_ *provider, err error) {
|
|||
if err != nil {
|
||||
return
|
||||
}
|
||||
conn := pool.Get(context.TODO())
|
||||
defer pool.Put(conn)
|
||||
err = initSchema(conn)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
writes := make(chan writeRequest)
|
||||
prov := &provider{pool: pool, writes: writes, opts: opts}
|
||||
runtime.SetFinalizer(prov, func(p *provider) {
|
||||
|
|
Loading…
Reference in New Issue