-
Notifications
You must be signed in to change notification settings - Fork 0
/
router.go
38 lines (35 loc) · 1.19 KB
/
router.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package main
import (
"github.com/Ankr-Shanghai/chainkv/types"
)
type Handler func(kv *kvserver, req *types.Request) *types.Response
var (
handleOps = map[types.ReqType]Handler{
types.REQ_TYPE_PUT: PutHandler,
types.REQ_TYPE_GET: GetHandler,
types.REQ_TYPE_DEL: DelHandler,
types.REQ_TYPE_HAS: HasHandler,
types.REQ_TYPE_FLUSH: FlushDBHandler,
// batch
types.REQ_TYPE_BATCH_NEW: NewBatchHandler,
types.REQ_TYPE_BATCH_PUT: BatchPutHandler,
types.REQ_TYPE_BATCH_DEL: BatchDelHandler,
types.REQ_TYPE_BATCH_WRITE: BatchWriteHandler,
types.REQ_TYPE_BATCH_RESET: BatchResetHandler,
types.REQ_TYPE_BATCH_CLOSE: BatchCloseHandler,
// iter
types.REQ_TYPE_ITER_NEW: NewIteratorHandler,
types.REQ_TYPE_ITER_NEXT: IterNextHandler,
types.REQ_TYPE_ITER_KEY: IterKeyHandler,
types.REQ_TYPE_ITER_VAL: IterValHandler,
types.REQ_TYPE_ITER_ERROR: IterErrorHandler,
types.REQ_TYPE_ITER_CLOSE: IterCloseHandler,
// snap
types.REQ_TYPE_SNAP_NEW: NewSnapHandler,
types.REQ_TYPE_SNAP_HAS: SnapHasHandler,
types.REQ_TYPE_SNAP_GET: SnapGetHandler,
types.REQ_TYPE_SNAP_RELEASE: SnapReleaseHandler,
// sequence
types.REQ_TYPE_SEQ_GET: GetSequenceHandler,
}
)