Skip to content

Commit

Permalink
Mini
Browse files Browse the repository at this point in the history
  • Loading branch information
claygod committed Jul 1, 2018
1 parent e9f68c1 commit 067b06e
Show file tree
Hide file tree
Showing 4 changed files with 1,050 additions and 100 deletions.
35 changes: 21 additions & 14 deletions adb_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,21 @@ type Adb struct {
path string
//queue *Queue
//queuesPool [256]*queue.Queue
batcher *batcher.Batcher
wal *wal.Wal
ch chan *batcher.Task
ch2 chan *batcher.Task
time *time.Time
symbol *Symbol
batcher *batcher.Batcher
wal *wal.Wal
snapshot *Snapshoter
ch chan *batcher.Task
ch2 chan *batcher.Task
time *time.Time
symbol *Symbol
}

func New(path string) (*Adb, error) {
// ToDo: exists dir ?

// проверка на то, как закончилась последняя сессия
// проводится ДО запуска базы !!!

symbol := newSymbol()
fileName := "start.txt"
wal, err := wal.New(path, fileName, symbol.Separator1) //newWal()
Expand All @@ -50,14 +55,15 @@ func New(path string) (*Adb, error) {
accounts: newAccounts(symbol),
//answers: newAnswers(),
//queue: q,
state: stateClosed,
path: path,
batcher: b,
wal: wal,
ch: ch,
ch2: ch2,
time: &time.Time{},
symbol: symbol,
state: stateClosed,
path: path,
batcher: b,
wal: wal,
snapshot: newSnapshoter(symbol, path),
ch: ch,
ch2: ch2,
time: &time.Time{},
symbol: symbol,
}

b.SetBatchSize(sizeBucket) //.Start()
Expand All @@ -78,6 +84,7 @@ func (a *Adb) Stop() {
func (a *Adb) Save() {
a.Stop()
a.saveToDisk()
a.snapshot.clean()
a.Start()
}

Expand Down
1 change: 1 addition & 0 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const (
const sizeBucket int64 = 256
const logExt string = ".log"
const dbExt string = ".db"
const snapExt string = ".snap"

/*
const (
Expand Down
Loading

0 comments on commit 067b06e

Please sign in to comment.