-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
41 lines (37 loc) · 991 Bytes
/
main.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
39
40
41
package main
import (
"flag"
"log"
"github.com/vladem/btree/btree"
"github.com/vladem/btree/server"
"github.com/vladem/btree/storage"
)
func main() {
path := flag.String("path", "./db", "path to a file to persist data")
flag.Parse()
maxKeysCount := uint32(11)
config := storage.TConfig{PageSizeBytes: 1024, FilePath: *path, MaxCellsCount: maxKeysCount}
strg, err := storage.MakeNodeStorage(config)
if err != nil {
log.Fatalf("failed to create storage with error [%v]\n", err)
}
defer strg.Close()
tree := btree.MakePagedBTree(strg, maxKeysCount)
if tree == nil {
log.Fatalf("failed to create a tree\n")
}
cfg := server.ServerConfig{
Port: "8080",
Workers: 2,
TelnetMode: true,
}
server, err := server.MakeServer(cfg, tree)
if err != nil {
log.Fatalf("failed to create server with error [%v]\n", err)
}
err = server.Serve(make(chan struct{}))
if err != nil {
log.Printf("serve finished with error [%v]\n", err)
}
log.Printf("finished\n")
}