feat: integrate DB with Open/Close/Put/Delete/Get
- Add db.go with DB struct: Open/Close/Put/Delete/Get/GetDurableSequence/IsWriteStopped - Add db_test.go with lifecycle, put/get, delete, recovery, and corruption tests - Extract sentinel errors to errkit/ leaf package to break import cycle (wal -> go_kv) - Update wal/sequence.go, wal/writer.go to import errkit instead of root package - Root errors.go re-exports from errkit for backward compatibility Phase 1 Wave 4d complete (T19).
This commit is contained in:
+7
-7
@@ -6,7 +6,7 @@ import (
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
go_kv "github.com/dailz/go-kv"
|
||||
"github.com/dailz/go-kv/errkit"
|
||||
"github.com/dailz/go-kv/config"
|
||||
"github.com/dailz/go-kv/memtable"
|
||||
)
|
||||
@@ -131,7 +131,7 @@ func (ww *WalWriter) processRemaining() {
|
||||
|
||||
func (ww *WalWriter) processBatch(requests []*CommitRequest) {
|
||||
if ww.writeStopped.Load() {
|
||||
ww.sendError(requests, go_kv.ErrWriteStopped)
|
||||
ww.sendError(requests, errkit.ErrWriteStopped)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -159,20 +159,20 @@ func (ww *WalWriter) processBatch(requests []*CommitRequest) {
|
||||
}
|
||||
|
||||
if err := ww.segManager.AppendBatch(encoded); err != nil {
|
||||
ww.stopWithError(requests, go_kv.ErrCommitUnknown)
|
||||
ww.stopWithError(requests, errkit.ErrCommitUnknown)
|
||||
return
|
||||
}
|
||||
|
||||
active := ww.memTables.GetActive()
|
||||
if err := writePending(active, entries, baseSequence); err != nil {
|
||||
abortRange(active, baseSequence, lastSequence)
|
||||
ww.stopWithError(requests, go_kv.ErrCommitUnknown)
|
||||
ww.stopWithError(requests, errkit.ErrCommitUnknown)
|
||||
return
|
||||
}
|
||||
|
||||
if err := ww.segManager.Sync(); err != nil {
|
||||
abortRange(active, baseSequence, lastSequence)
|
||||
ww.stopWithError(requests, go_kv.ErrCommitUnknown)
|
||||
ww.stopWithError(requests, errkit.ErrCommitUnknown)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -263,7 +263,7 @@ func (ww *WalWriter) sendSuccess(requests []*CommitRequest, baseSequence uint64,
|
||||
// Put stores key with value.
|
||||
func (ww *WalWriter) Put(key, value []byte) error {
|
||||
if ww.writeStopped.Load() {
|
||||
return go_kv.ErrWriteStopped
|
||||
return errkit.ErrWriteStopped
|
||||
}
|
||||
|
||||
req := ww.queue.Submit([]*WalEntry{{
|
||||
@@ -279,7 +279,7 @@ func (ww *WalWriter) Put(key, value []byte) error {
|
||||
// Delete removes key.
|
||||
func (ww *WalWriter) Delete(key []byte) error {
|
||||
if ww.writeStopped.Load() {
|
||||
return go_kv.ErrWriteStopped
|
||||
return errkit.ErrWriteStopped
|
||||
}
|
||||
|
||||
req := ww.queue.Submit([]*WalEntry{{
|
||||
|
||||
Reference in New Issue
Block a user