Skip to content

Commit 6790ef1

Browse files
committed
Init
0 parents  commit 6790ef1

File tree

4 files changed

+121
-0
lines changed

4 files changed

+121
-0
lines changed

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License
2+
3+
Copyright (c) 2016 Łukasz Magiera
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

Makefile

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
2+
test: deps
3+
go test -race -v ./...
4+
5+
export IPFS_API ?= v04x.ipfs.io
6+
7+
gx:
8+
go get -u github.com/whyrusleeping/gx
9+
go get -u github.com/whyrusleeping/gx-go
10+
11+
deps: gx
12+
gx --verbose install --global
13+
gx-go rewrite
14+
go get -t ./...

datastore.go

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
package badger
2+
3+
import (
4+
badger "github.com/dgraph-io/badger/badger"
5+
ds "github.com/ipfs/go-datastore"
6+
dsq "github.com/ipfs/go-datastore/query"
7+
"github.com/pkg/errors"
8+
)
9+
10+
type datastore struct {
11+
DB *badger.KV
12+
}
13+
14+
func NewDatastore(path string) (*datastore, error) {
15+
opt := badger.DefaultOptions
16+
opt.Dir = path
17+
opt.ValueDir = path
18+
opt.ValueGCThreshold = 0
19+
20+
kv, err := badger.NewKV(&opt)
21+
if err != nil {
22+
return nil, err
23+
}
24+
25+
return &datastore{
26+
DB: kv,
27+
}, nil
28+
}
29+
30+
func (d *datastore) Put(key ds.Key, value interface{}) (err error) {
31+
return errors.New("not implemented")
32+
}
33+
34+
func (d *datastore) Get(key ds.Key) (value interface{}, err error) {
35+
return nil, errors.New("not implemented")
36+
}
37+
38+
func (d *datastore) Has(key ds.Key) (exists bool, err error) {
39+
return nil, errors.New("not implemented")
40+
}
41+
42+
func (d *datastore) Delete(key ds.Key) (err error) {
43+
return errors.New("not implemented")
44+
}
45+
46+
func (d *datastore) Query(q dsq.Query) (dsq.Results, error) {
47+
return d.QueryNew(q)
48+
}
49+
50+
func (d *datastore) QueryNew(q dsq.Query) (dsq.Results, error) {
51+
return nil, errors.New("not implemented")
52+
}
53+
54+
func (d *datastore) QueryOrig(q dsq.Query) (dsq.Results, error) {
55+
return nil, errors.New("not implemented")
56+
}
57+
58+
func (d *datastore) Close() (err error) {
59+
return d.DB.Close()
60+
}
61+
62+
func (d *datastore) Batch() (ds.Batch, error) {
63+
return nil, errors.New("not implemented")
64+
}

package.json

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"author": "magik6k",
3+
"bugs": {
4+
"url": "https://github.com/ipfs/go-ds-badger"
5+
},
6+
"gx": {
7+
"dvcsimport": "github.com/ipfs/go-ds-badger"
8+
},
9+
"gxDependencies": [
10+
{
11+
"author": "jbenet",
12+
"hash": "QmRWDav6mzWseLWeYfVd5fvUKiVe9xNH29YfMF438fG364",
13+
"name": "go-datastore",
14+
"version": "1.2.0"
15+
}
16+
],
17+
"gxVersion": "0.8.0",
18+
"language": "go",
19+
"license": "",
20+
"name": "go-ds-badger",
21+
"version": "0.1.0"
22+
}

0 commit comments

Comments
 (0)