add context to LockedRepo#Datastore().

This commit is contained in:
Raúl Kripalani
2021-01-26 11:01:43 +00:00
parent ce3af308ed
commit a1da1dab85
21 changed files with 42 additions and 29 deletions
+2 -1
View File
@@ -1,6 +1,7 @@
package repo
import (
"context"
"os"
"path/filepath"
@@ -67,7 +68,7 @@ func (fsr *fsLockedRepo) openDatastores(readonly bool) (map[string]datastore.Bat
return out, nil
}
func (fsr *fsLockedRepo) Datastore(ns string) (datastore.Batching, error) {
func (fsr *fsLockedRepo) Datastore(_ context.Context, ns string) (datastore.Batching, error) {
fsr.dsOnce.Do(func() {
fsr.ds, fsr.dsErr = fsr.openDatastores(fsr.readonly)
})
+4 -1
View File
@@ -52,7 +52,10 @@ type LockedRepo interface {
Close() error
// Returns datastore defined in this repo.
Datastore(namespace string) (datastore.Batching, error)
// The supplied context must only be used to initialize the datastore.
// The implementation should not retain the context for usage throughout
// the lifecycle.
Datastore(ctx context.Context, namespace string) (datastore.Batching, error)
// Blockstore returns an IPLD blockstore for the requested domain.
// The supplied context must only be used to initialize the blockstore.
+1 -1
View File
@@ -237,7 +237,7 @@ func (lmem *lockedMemRepo) Close() error {
}
func (lmem *lockedMemRepo) Datastore(ns string) (datastore.Batching, error) {
func (lmem *lockedMemRepo) Datastore(_ context.Context, ns string) (datastore.Batching, error) {
if err := lmem.checkToken(); err != nil {
return nil, err
}