This commit is contained in:
2026-06-15 05:32:15 +03:00
parent 80309aab99
commit ca125c99d2
16 changed files with 685 additions and 1350 deletions

View File

@@ -10,19 +10,13 @@ import (
"time"
"gordenko.dev/dima/qb"
"gordenko.dev/dima/qb/atree"
"gordenko.dev/dima/qb/inbox"
"gordenko.dev/dima/qb/recovery"
"gordenko.dev/dima/qb/storage"
"gordenko.dev/dima/qb/worker"
)
// type metricLockEntry struct {
// XLock bool
// RLocks int
// WaitQueue []any
// }
//metricLockEntries map[uint32]*metricLockEntry
type Database struct {
mutex sync.Mutex
dir string
@@ -30,6 +24,7 @@ type Database struct {
workerInbox *inbox.Inbox
worker *worker.Worker
storage *storage.Writer
atree *atree.Atree
tcpPort int
logfile *os.File
logger *log.Logger
@@ -122,8 +117,6 @@ func New(opt Options) (_ *Database, err error) {
return nil, fmt.Errorf("storage.NewWriter: %s", err)
}
fmt.Println("storage created")
s.worker = worker.New(worker.Options{
Inbox: s.workerInbox,
StorageInbox: storageInbox,
@@ -133,7 +126,14 @@ func New(opt Options) (_ *Database, err error) {
ExitCh: opt.ExitCh,
WaitGroup: opt.WaitGroup,
})
fmt.Println("worker created")
s.atree, err = atree.New(atree.Options{
DataFile: dataFile,
IndexFile: indexFile,
})
if err != nil {
return nil, fmt.Errorf("atree.New: %s", err)
}
return s, nil
}
@@ -146,13 +146,6 @@ func (s *Database) ListenAndServe() (err error) {
//s.waitGroup.Add(1)
go s.storage.Run()
// s.atree, err = atree.New(atree.Options{
// Dir: s.dir,
// DatabaseName: s.databaseName,
// })
// if err != nil {
// return fmt.Errorf("atree.New: %s", err)
// }
// s.atree.Run()
s.waitGroup.Add(1)