mirror of
https://github.com/talent-plan/tinykv.git
synced 2025-03-14 20:00:39 +08:00
Server: Extract raw api to be implemented in Project1 into raw_api.go (#285)
* Extract raw api to be implemented in Project1 into raw_api.go * Run go fmt to apply automatic formatter and delete redundant comments * Add comments and hints to each function Co-authored-by: tison <wander4096@gmail.com>
This commit is contained in:
parent
de3a408ed5
commit
bda1e7b85b
36
kv/server/raw_api.go
Normal file
36
kv/server/raw_api.go
Normal file
@ -0,0 +1,36 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/pingcap-incubator/tinykv/proto/pkg/kvrpcpb"
|
||||
)
|
||||
|
||||
// The functions below are Server's Raw API. (implements TinyKvServer).
|
||||
// Some helper methods can be found in sever.go in the current directory
|
||||
|
||||
// RawGet return the corresponding Get response based on RawGetRequest's CF and Key fields
|
||||
func (server *Server) RawGet(_ context.Context, req *kvrpcpb.RawGetRequest) (*kvrpcpb.RawGetResponse, error) {
|
||||
// Your Code Here (1).
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// RawPut puts the target data into storage and returns the corresponding response
|
||||
func (server *Server) RawPut(_ context.Context, req *kvrpcpb.RawPutRequest) (*kvrpcpb.RawPutResponse, error) {
|
||||
// Your Code Here (1).
|
||||
// Hint: Consider using Storage.Modify to store data to be modified
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// RawDelete delete the target data from storage and returns the corresponding response
|
||||
func (server *Server) RawDelete(_ context.Context, req *kvrpcpb.RawDeleteRequest) (*kvrpcpb.RawDeleteResponse, error) {
|
||||
// Your Code Here (1).
|
||||
// Hint: Consider using Storage.Modify to store data to be deleted
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// RawScan scan the data starting from the start key up to limit. and return the corresponding result
|
||||
func (server *Server) RawScan(_ context.Context, req *kvrpcpb.RawScanRequest) (*kvrpcpb.RawScanResponse, error) {
|
||||
// Your Code Here (1).
|
||||
// Hint: Consider using reader.IterCF
|
||||
return nil, nil
|
||||
}
|
@ -35,27 +35,6 @@ func NewServer(storage storage.Storage) *Server {
|
||||
|
||||
// The below functions are Server's gRPC API (implements TinyKvServer).
|
||||
|
||||
// Raw API.
|
||||
func (server *Server) RawGet(_ context.Context, req *kvrpcpb.RawGetRequest) (*kvrpcpb.RawGetResponse, error) {
|
||||
// Your Code Here (1).
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (server *Server) RawPut(_ context.Context, req *kvrpcpb.RawPutRequest) (*kvrpcpb.RawPutResponse, error) {
|
||||
// Your Code Here (1).
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (server *Server) RawDelete(_ context.Context, req *kvrpcpb.RawDeleteRequest) (*kvrpcpb.RawDeleteResponse, error) {
|
||||
// Your Code Here (1).
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (server *Server) RawScan(_ context.Context, req *kvrpcpb.RawScanRequest) (*kvrpcpb.RawScanResponse, error) {
|
||||
// Your Code Here (1).
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// Raft commands (tinykv <-> tinykv)
|
||||
// Only used for RaftStorage, so trivially forward it.
|
||||
func (server *Server) Raft(stream tinykvpb.TinyKv_RaftServer) error {
|
||||
|
Loading…
Reference in New Issue
Block a user