wip: testing

master
jdl 2022-07-26 14:13:41 +02:00
parent a3ca69101e
commit 32b0618505
4 changed files with 27 additions and 9 deletions

View File

@ -62,18 +62,23 @@ func (db *Database) Start() {
}
func (db *Database) WALStatus() (ws WALStatus) {
ws.MaxID = db.kv.WALMaxSeqNum()
ws.MaxAppliedID = db.kv.MaxSeqNum()
ws.MaxSeqNumKV = db.kv.WALMaxSeqNum()
ws.MaxSeqNumWAL = db.kv.MaxSeqNum()
return
}
func (db *Database) Close() {
db.kv.Close()
db.lock.Close()
if db.kv != nil {
db.kv.Close()
db.kv = nil
}
if db.lock != nil {
db.lock.Close()
db.lock = nil
}
}
// -----------------
db.kv = kvstore.NewSecondary(root)-----------------------------------------------------------
// ----------------------------------------------------------------------------
func (db *Database) onStore(collection string, id uint64, data []byte) {
c, ok := db.collections[collection]

View File

@ -5,7 +5,7 @@ import "time"
func (db *Database) waitForWAL() {
for {
status := db.WALStatus()
if status.MaxAppliedID == status.MaxID {
if status.MaxSeqNumWAL == status.MaxSeqNumKV {
return
}
time.Sleep(100 * time.Millisecond)

13
main_test.go Normal file
View File

@ -0,0 +1,13 @@
package mdb
import (
"math/rand"
"os"
"testing"
"time"
)
func TestMain(m *testing.M) {
rand.Seed(time.Now().UnixNano())
os.Exit(m.Run())
}

View File

@ -1,8 +1,8 @@
package mdb
type WALStatus struct {
MaxID uint64 // TODO: WALMaxSeqNum
MaxAppliedID uint64 // TODO: KVMaxSeqNum
MaxSeqNumKV uint64
MaxSeqNumWAL uint64
}
type itemIndex[T any] interface {