|
@@ -44,6 +44,10 @@ type store struct {
|
|
|
stopc chan struct{}
|
|
stopc chan struct{}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+func New(path string) KV {
|
|
|
|
|
+ return newStore(path)
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
func newStore(path string) *store {
|
|
func newStore(path string) *store {
|
|
|
s := &store{
|
|
s := &store{
|
|
|
b: backend.New(path, batchInterval, batchLimit),
|
|
b: backend.New(path, batchInterval, batchLimit),
|
|
@@ -285,7 +289,7 @@ func (s *store) rangeKeys(key, end []byte, limit, rangeRev int64) (kvs []storage
|
|
|
log.Fatalf("storage: cannot unmarshal event: %v", err)
|
|
log.Fatalf("storage: cannot unmarshal event: %v", err)
|
|
|
}
|
|
}
|
|
|
if e.Type == storagepb.PUT {
|
|
if e.Type == storagepb.PUT {
|
|
|
- kvs = append(kvs, e.Kv)
|
|
|
|
|
|
|
+ kvs = append(kvs, *e.Kv)
|
|
|
}
|
|
}
|
|
|
if limit > 0 && len(kvs) >= int(limit) {
|
|
if limit > 0 && len(kvs) >= int(limit) {
|
|
|
break
|
|
break
|
|
@@ -309,7 +313,7 @@ func (s *store) put(key, value []byte, rev int64) {
|
|
|
ver = ver + 1
|
|
ver = ver + 1
|
|
|
event := storagepb.Event{
|
|
event := storagepb.Event{
|
|
|
Type: storagepb.PUT,
|
|
Type: storagepb.PUT,
|
|
|
- Kv: storagepb.KeyValue{
|
|
|
|
|
|
|
+ Kv: &storagepb.KeyValue{
|
|
|
Key: key,
|
|
Key: key,
|
|
|
Value: value,
|
|
Value: value,
|
|
|
CreateIndex: c,
|
|
CreateIndex: c,
|
|
@@ -388,7 +392,7 @@ func (s *store) delete(key []byte, mainrev int64) bool {
|
|
|
|
|
|
|
|
event := storagepb.Event{
|
|
event := storagepb.Event{
|
|
|
Type: storagepb.DELETE,
|
|
Type: storagepb.DELETE,
|
|
|
- Kv: storagepb.KeyValue{
|
|
|
|
|
|
|
+ Kv: &storagepb.KeyValue{
|
|
|
Key: key,
|
|
Key: key,
|
|
|
},
|
|
},
|
|
|
}
|
|
}
|