Skip to content

Commit

Permalink
address jbenets comments on the pull request #1
Browse files Browse the repository at this point in the history
  • Loading branch information
whyrusleeping committed Sep 8, 2014
1 parent 2ffbdab commit 2ba1029
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
10 changes: 5 additions & 5 deletions basic_ds.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ func (d *MapDatastore) Delete(key Key) (err error) {
return nil
}

func (d *MapDatastore) KeyList() []Key {
func (d *MapDatastore) KeyList() ([]Key, error) {
var keys []Key
for k, _ := range d.values {
keys = append(keys, k)
}
return keys
return keys, nil
}

// NullDatastore stores nothing, but conforms to the API.
Expand Down Expand Up @@ -74,8 +74,8 @@ func (d *NullDatastore) Delete(key Key) (err error) {
return nil
}

func (d *NullDatastore) KeyList() []Key {
return nil
func (d *NullDatastore) KeyList() ([]Key, error) {
return nil, nil
}

// LogDatastore logs all accesses through the datastore.
Expand Down Expand Up @@ -112,7 +112,7 @@ func (d *LogDatastore) Delete(key Key) (err error) {
return d.Child.Delete(key)
}

func (d *LogDatastore) KeyList() []Key {
func (d *LogDatastore) KeyList() ([]Key, error) {
log.Printf("%s: Get KeyList.", d.Name)
return d.Child.KeyList()
}
2 changes: 1 addition & 1 deletion datastore.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ type Datastore interface {
Delete(key Key) (err error)

// Returns a list of keys in the datastore
KeyList() []Key
KeyList() ([]Key, error)
}

// Errors
Expand Down
5 changes: 3 additions & 2 deletions elastigo/datastore.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package elastigo

import (
"errors"
"fmt"
"net/url"
"strings"
Expand Down Expand Up @@ -111,8 +112,8 @@ func (d *Datastore) Delete(key ds.Key) (err error) {
return nil
}

func (d *Datastore) KeyList() []ds.Key {
panic("Not yet implemented!")
func (d *Datastore) KeyList() ([]ds.Key, error) {
return nil, errors.New("Not yet implemented!")
}

// Hash a key and return the first 16 hex chars of its blake2b hash.
Expand Down
4 changes: 2 additions & 2 deletions leveldb/datastore.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,13 @@ func (d *Datastore) Delete(key ds.Key) (err error) {
return err
}

func (d *Datastore) KeyList() []ds.Key {
func (d *Datastore) KeyList() ([]ds.Key, error) {
i := d.DB.NewIterator(nil, nil)
var keys []ds.Key
for ; i.Valid(); i.Next() {
keys = append(keys, ds.NewKey(string(i.Key())))
}
return keys
return keys, nil
}

// LevelDB needs to be closed.
Expand Down

0 comments on commit 2ba1029

Please sign in to comment.