2020-04-30 15:07:27 +08:00
|
|
|
package storage
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/pingcap-incubator/tinykv/kv/util/engine_util"
|
|
|
|
"github.com/pingcap-incubator/tinykv/proto/pkg/kvrpcpb"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Storage represents the internal-facing server part of TinyKV, it handles sending and receiving from other
|
|
|
|
// TinyKV nodes. As part of that responsibility, it also reads and writes data to disk (or semi-permanent memory).
|
|
|
|
type Storage interface {
|
|
|
|
Start() error
|
|
|
|
Stop() error
|
|
|
|
Write(ctx *kvrpcpb.Context, batch []Modify) error
|
|
|
|
Reader(ctx *kvrpcpb.Context) (StorageReader, error)
|
|
|
|
}
|
|
|
|
|
|
|
|
type StorageReader interface {
|
2020-03-22 00:04:20 +08:00
|
|
|
// When the key doesn't exist, return nil for the value
|
2020-04-30 15:07:27 +08:00
|
|
|
GetCF(cf string, key []byte) ([]byte, error)
|
|
|
|
IterCF(cf string) engine_util.DBIterator
|
|
|
|
Close()
|
|
|
|
}
|