mirror of
https://github.com/ipfs/kubo.git
synced 2026-02-24 20:07:45 +08:00
refactor(fsrepo) add interface to make it easier to understand how to extend the package
This commit is contained in:
parent
c364b4c34c
commit
f37646bf19
@ -7,6 +7,7 @@ import (
|
||||
)
|
||||
|
||||
var _ component = &configComponent{}
|
||||
var _ componentInitializationChecker = configComponentIsInitialized
|
||||
|
||||
// configComponent abstracts the config component of the FSRepo.
|
||||
// NB: create with makeConfigComponent function.
|
||||
|
||||
@ -56,6 +56,7 @@ type component interface {
|
||||
Open() error
|
||||
io.Closer
|
||||
}
|
||||
type componentInitializationChecker func(path string) bool
|
||||
|
||||
// At returns a handle to an FSRepo at the provided |path|.
|
||||
func At(repoPath string) *FSRepo {
|
||||
@ -256,7 +257,7 @@ func IsInitialized(path string) bool {
|
||||
|
||||
// componentInitCheckers are functions that indicate whether the component
|
||||
// is isInitialized
|
||||
var componentInitCheckers = []func(path string) bool{
|
||||
var componentInitCheckers = []componentInitializationChecker{
|
||||
configComponentIsInitialized,
|
||||
// TODO add datastore component initialization checker
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user