-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
featrue: Include go-ds-pebble as built-in plugin #10367
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,6 +51,17 @@ Uses [badger](https://github.com/dgraph-io/badger) as a key value store. | |
} | ||
``` | ||
|
||
## pebbleds | ||
|
||
Uses [pebble](https://github.com/cockroachdb/pebble) as a key value store | ||
|
||
```json | ||
{ | ||
"type": "pebbleds", | ||
"path": "<location of pebble inside repo>" | ||
} | ||
``` | ||
Comment on lines
+54
to
+63
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @hsanjuan I know pebble is used by default in IPFS Cluster, and there is a lot of custom configuration in https://github.com/ipfs-cluster/ipfs-cluster/blob/v1.0.8/datastore/pebble/config.go#L25-L70 Two questions:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @lidel it makes sense to expose them, to be honest. Why not? I would expose them explicitally like cluster does. It is the only way to adjust things to usage, unlike the current badger-datastore defaults. For implicit defaults, you need to look into what Kubo does. Kubo has its own block-cache, etc. so might as well disable/reduce pebble's cache, for example. Also need to adapt levels and granularity to the average 256K default block size. |
||
|
||
## mount | ||
|
||
Allows specified datastores to handle keys prefixed with a given path. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package pebbleds | ||
|
||
import ( | ||
"fmt" | ||
"path/filepath" | ||
|
||
"github.com/cockroachdb/pebble" | ||
"github.com/ipfs/kubo/plugin" | ||
"github.com/ipfs/kubo/repo" | ||
"github.com/ipfs/kubo/repo/fsrepo" | ||
|
||
pebbleds "github.com/ipfs/go-ds-pebble" | ||
) | ||
|
||
var Plugins = []plugin.Plugin{ | ||
&pebbledsPlugin{}, | ||
} | ||
|
||
type pebbledsPlugin struct{} | ||
|
||
var _ plugin.PluginDatastore = (*pebbledsPlugin)(nil) | ||
|
||
func (*pebbledsPlugin) Name() string { | ||
return "ds-pebble" | ||
} | ||
|
||
func (*pebbledsPlugin) Version() string { | ||
return "" | ||
} | ||
|
||
func (*pebbledsPlugin) Init(_ *plugin.Environment) error { | ||
return nil | ||
} | ||
|
||
func (*pebbledsPlugin) DatastoreTypeName() string { | ||
return "pebbleds" | ||
} | ||
|
||
type datastoreConfig struct { | ||
path string | ||
} | ||
|
||
func (*pebbledsPlugin) DatastoreConfigParser() fsrepo.ConfigFromMap { | ||
return func(params map[string]interface{}) (fsrepo.DatastoreConfig, error) { | ||
var c datastoreConfig | ||
var ok bool | ||
|
||
c.path, ok = params["path"].(string) | ||
if !ok { | ||
return nil, fmt.Errorf("'path' field is missing or not string") | ||
} | ||
|
||
return &c, nil | ||
} | ||
} | ||
|
||
func (c *datastoreConfig) DiskSpec() fsrepo.DiskSpec { | ||
return map[string]interface{}{ | ||
"type": "pebbleds", | ||
"path": c.path, | ||
} | ||
} | ||
|
||
func (c *datastoreConfig) Create(path string) (repo.Datastore, error) { | ||
p := c.path | ||
if !filepath.IsAbs(p) { | ||
p = filepath.Join(path, p) | ||
} | ||
return pebbleds.NewDatastore(p, &pebble.Options{}) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.