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
+8 -19
View File
@@ -1,22 +1,11 @@
package go_kv
import "errors"
import "github.com/dailz/go-kv/errkit"
// ErrCommitUnknown indicates the commit result is indeterminate: the WAL write
// was attempted but the caller cannot assume the write definitely failed or
// succeeded. The caller must query the commit state before retrying.
var ErrCommitUnknown = errors.New("go-kv: commit result unknown")
// ErrWriteStopped indicates the engine has entered a write-stopped state and
// rejects all subsequent writes.
var ErrWriteStopped = errors.New("go-kv: write stopped")
// ErrSequenceExhausted indicates the sequence number space is exhausted. The
// engine enters a terminal state requiring database migration or rebuild.
var ErrSequenceExhausted = errors.New("go-kv: sequence exhausted")
// ErrWALCorrupted indicates WAL data corruption was detected.
var ErrWALCorrupted = errors.New("go-kv: WAL corrupted")
// ErrInvalidConfig indicates an invalid configuration was provided.
var ErrInvalidConfig = errors.New("go-kv: invalid config")
var (
ErrCommitUnknown = errkit.ErrCommitUnknown
ErrWriteStopped = errkit.ErrWriteStopped
ErrSequenceExhausted = errkit.ErrSequenceExhausted
ErrWALCorrupted = errkit.ErrWALCorrupted
ErrInvalidConfig = errkit.ErrInvalidConfig
)