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:
dailz
2026-06-12 14:10:56 +08:00
parent 294ab9181f
commit 0fe1530e25
9 changed files with 415 additions and 37 deletions
+4 -4
View File
@@ -7,7 +7,7 @@ import (
"sync/atomic"
"testing"
"github.com/dailz/go-kv"
"github.com/dailz/go-kv/errkit"
)
func TestSequenceAllocation(t *testing.T) {
@@ -49,7 +49,7 @@ func TestSequenceOverflow(t *testing.T) {
// Remaining: MaxUint64-2, MaxUint64-1, MaxUint64 = 3 slots.
// Asking for 5 should overflow.
_, err := sm.AllocateBatch(5)
if !errors.Is(err, go_kv.ErrSequenceExhausted) {
if !errors.Is(err, errkit.ErrSequenceExhausted) {
t.Fatalf("expected ErrSequenceExhausted, got %v", err)
}
@@ -64,7 +64,7 @@ func TestSequenceOverflow(t *testing.T) {
// Now any further allocation should fail.
_, err = sm.AllocateBatch(1)
if !errors.Is(err, go_kv.ErrSequenceExhausted) {
if !errors.Is(err, errkit.ErrSequenceExhausted) {
t.Fatalf("expected ErrSequenceExhausted after exhaustion, got %v", err)
}
}
@@ -108,7 +108,7 @@ func TestZeroCountRejected(t *testing.T) {
sm := NewSequenceManager(0)
_, err := sm.AllocateBatch(0)
if !errors.Is(err, go_kv.ErrSequenceExhausted) {
if !errors.Is(err, errkit.ErrSequenceExhausted) {
t.Fatalf("expected ErrSequenceExhausted for count=0, got %v", err)
}
}