Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
go-ipfs
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
GitHub Mirror
ipfs
go-ipfs
Commits
7b9cfda0
Commit
7b9cfda0
authored
Jul 4, 2018
by
Jeromy Johnson
Committed by
Łukasz Magiera
Sep 23, 2018
Browse files
Options
Downloads
Patches
Plain Diff
add support for datastore plugins
License: MIT Signed-off-by:
Jeromy
<
jeromyj@gmail.com
>
parent
238bd012
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
plugin/datastore.go
+14
-0
14 additions, 0 deletions
plugin/datastore.go
plugin/loader/initializer.go
+7
-1
7 additions, 1 deletion
plugin/loader/initializer.go
repo/fsrepo/datastores.go
+16
-1
16 additions, 1 deletion
repo/fsrepo/datastores.go
with
37 additions
and
2 deletions
plugin/datastore.go
0 → 100644
+
14
−
0
View file @
7b9cfda0
package
plugin
import
(
"github.com/ipfs/go-ipfs/repo/fsrepo"
)
// PluginDatastore is an interface that can be implemented to add handlers for
// for different datastores
type
PluginDatastore
interface
{
Plugin
DatastoreTypeName
()
string
DatastoreConfigParser
()
fsrepo
.
ConfigFromMap
}
This diff is collapsed.
Click to expand it.
plugin/loader/initializer.go
+
7
−
1
View file @
7b9cfda0
...
@@ -3,8 +3,9 @@ package loader
...
@@ -3,8 +3,9 @@ package loader
import
(
import
(
"github.com/ipfs/go-ipfs/core/coredag"
"github.com/ipfs/go-ipfs/core/coredag"
"github.com/ipfs/go-ipfs/plugin"
"github.com/ipfs/go-ipfs/plugin"
"g
x/ipfs/QmWLWmRVSiagqP15jczsGME1qpob6HDbtbHAY2he9W5iUo/opentracing-g
o"
"g
ithub.com/ipfs/go-ipfs/repo/fsrep
o"
"gx/ipfs/QmWLWmRVSiagqP15jczsGME1qpob6HDbtbHAY2he9W5iUo/opentracing-go"
ipld
"gx/ipfs/QmdDXJs4axxefSPgK6Y1QhpJWKuDPnGJiqgq4uncb4rFHL/go-ipld-format"
ipld
"gx/ipfs/QmdDXJs4axxefSPgK6Y1QhpJWKuDPnGJiqgq4uncb4rFHL/go-ipld-format"
)
)
...
@@ -32,6 +33,11 @@ func run(plugins []plugin.Plugin) error {
...
@@ -32,6 +33,11 @@ func run(plugins []plugin.Plugin) error {
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
case
plugin
.
PluginDatastore
:
err
:=
fsrepo
.
AddDatastoreConfigHandler
(
pl
.
DatastoreTypeName
(),
pl
.
DatastoreConfigParser
())
if
err
!=
nil
{
return
err
}
default
:
default
:
panic
(
pl
)
panic
(
pl
)
}
}
...
...
This diff is collapsed.
Click to expand it.
repo/fsrepo/datastores.go
+
16
−
1
View file @
7b9cfda0
...
@@ -36,7 +36,12 @@ type DatastoreConfig interface {
...
@@ -36,7 +36,12 @@ type DatastoreConfig interface {
Create
(
path
string
)
(
repo
.
Datastore
,
error
)
Create
(
path
string
)
(
repo
.
Datastore
,
error
)
}
}
// DiskSpec is the type returned by the DatastoreConfig's DiskSpec method
// DiskSpec is a minimal representation of the characteristic values of the
// datastore. If two diskspecs are the same, the loader assumes that they refer
// to exactly the same datastore. If they differ at all, it is assumed they are
// completely different datastores and a migration will be performed. Runtime
// values such as cache options or concurrency options should not be added
// here.
type
DiskSpec
map
[
string
]
interface
{}
type
DiskSpec
map
[
string
]
interface
{}
// Bytes returns a minimal JSON encoding of the DiskSpec
// Bytes returns a minimal JSON encoding of the DiskSpec
...
@@ -68,6 +73,16 @@ func init() {
...
@@ -68,6 +73,16 @@ func init() {
}
}
}
}
func
AddDatastoreConfigHandler
(
name
string
,
dsc
ConfigFromMap
)
error
{
_
,
ok
:=
datastores
[
name
]
if
ok
{
return
fmt
.
Errorf
(
"already have a datastore named %q"
,
name
)
}
datastores
[
name
]
=
dsc
return
nil
}
// AnyDatastoreConfig returns a DatastoreConfig from a spec based on
// AnyDatastoreConfig returns a DatastoreConfig from a spec based on
// the "type" parameter
// the "type" parameter
func
AnyDatastoreConfig
(
params
map
[
string
]
interface
{})
(
DatastoreConfig
,
error
)
{
func
AnyDatastoreConfig
(
params
map
[
string
]
interface
{})
(
DatastoreConfig
,
error
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
sign in
to comment