commit ff6142a639fd09cd3a4cedcaa129345829da007f
parent 05f006f0444e9925baf7d6fa4d03472d37f30bc9
Author: lash <dev@holbrook.no>
Date: Sun, 1 Sep 2024 20:49:02 +0100
Fix all broken db references
Diffstat:
25 files changed, 63 insertions(+), 51 deletions(-)
diff --git a/dev/gdbm/main.go b/dev/gdbm/main.go
@@ -1,4 +1,6 @@
// Executable gdbm processes a given directory recursively and inserts all template files, menu files and bytecode files into corresponding db.Db entries backed by a gdbm backend.
+//
+// TODO: Implement with db/gdbm
package main
import (
diff --git a/dev/interactive/main.go b/dev/interactive/main.go
@@ -8,6 +8,7 @@ import (
"git.defalsify.org/vise.git/engine"
"git.defalsify.org/vise.git/db"
+ fsdb "git.defalsify.org/vise.git/db/fs"
)
func main() {
@@ -27,7 +28,7 @@ func main() {
ctx := context.Background()
if persist != "" {
- store = db.NewFsDb()
+ store = fsdb.NewFsDb()
err := store.Connect(ctx, persist)
if err != nil {
fmt.Fprintf(os.Stderr, "db connect error: %v", err)
diff --git a/engine/default.go b/engine/default.go
@@ -9,13 +9,14 @@ import (
"git.defalsify.org/vise.git/resource"
"git.defalsify.org/vise.git/state"
"git.defalsify.org/vise.git/db"
+ fsdb "git.defalsify.org/vise.git/db/fs"
)
// NewDefaultEngine is a convenience function to instantiate a filesystem-backed engine with no output constraints.
func NewDefaultEngine(dir string, persistDb db.Db, session *string) (EngineIsh, error) {
st := state.NewState(0)
ctx := context.Background()
- store := db.NewFsDb()
+ store := fsdb.NewFsDb()
err := store.Connect(ctx, dir)
if err != nil {
return nil, err
@@ -56,7 +57,7 @@ func NewSizedEngine(dir string, size uint32, persistDb db.Db, session *string) (
st := state.NewState(0)
ca := cache.NewCache()
ctx := context.Background()
- store := db.NewFsDb()
+ store := fsdb.NewFsDb()
err := store.Connect(ctx, dir)
if err != nil {
return nil, err
diff --git a/engine/engine_test.go b/engine/engine_test.go
@@ -16,6 +16,7 @@ import (
"git.defalsify.org/vise.git/testdata"
"git.defalsify.org/vise.git/vm"
"git.defalsify.org/vise.git/db"
+ fsdb "git.defalsify.org/vise.git/db/fs"
)
var (
@@ -31,7 +32,7 @@ type testWrapper struct {
func newTestWrapper(path string, st *state.State) testWrapper {
ctx := context.Background()
- store := db.NewFsDb()
+ store := fsdb.NewFsDb()
store.Connect(ctx, path)
rs := resource.NewDbResource(store)
rs.With(db.DATATYPE_STATICLOAD)
diff --git a/engine/persist_test.go b/engine/persist_test.go
@@ -8,7 +8,7 @@ import (
"git.defalsify.org/vise.git/cache"
"git.defalsify.org/vise.git/persist"
"git.defalsify.org/vise.git/state"
- "git.defalsify.org/vise.git/db"
+ memdb "git.defalsify.org/vise.git/db/mem"
)
func TestRunPersist(t *testing.T) {
@@ -23,7 +23,7 @@ func TestRunPersist(t *testing.T) {
st := state.NewState(3)
ca := cache.NewCache().WithCacheSize(1024)
- store := db.NewMemDb()
+ store := memdb.NewMemDb()
store.Connect(ctx, "")
pr := persist.NewPersister(store).WithContent(&st, ca)
@@ -81,7 +81,7 @@ func TestEnginePersist(t *testing.T) {
st := state.NewState(3)
ca := cache.NewCache().WithCacheSize(1024)
- store := db.NewMemDb()
+ store := memdb.NewMemDb()
store.Connect(ctx, "")
pr := persist.NewPersister(store).WithContent(&st, ca)
diff --git a/examples/db/main.go b/examples/db/main.go
@@ -17,6 +17,7 @@ import (
"git.defalsify.org/vise.git/resource"
"git.defalsify.org/vise.git/state"
"git.defalsify.org/vise.git/db"
+ fsdb "git.defalsify.org/vise.git/db/fs"
"git.defalsify.org/vise.git/logging"
)
@@ -24,7 +25,7 @@ var (
logg = logging.NewVanilla()
baseDir = testdataloader.GetBasePath()
scriptDir = path.Join(baseDir, "examples", "db")
- store = db.NewFsDb()
+ store = fsdb.NewFsDb()
pr = persist.NewPersister(store)
data_selector = []byte("my_data")
)
diff --git a/examples/gdbm/main.go b/examples/gdbm/main.go
@@ -14,6 +14,8 @@ import (
"git.defalsify.org/vise.git/resource"
"git.defalsify.org/vise.git/state"
"git.defalsify.org/vise.git/db"
+ gdbmdb "git.defalsify.org/vise.git/db/gdbm"
+ fsdb "git.defalsify.org/vise.git/db/fs"
)
var (
@@ -34,7 +36,7 @@ func main() {
fmt.Fprintf(os.Stderr, "starting session at symbol '%s' using resource dir: %s\n", root, scriptDir)
st := state.NewState(0)
- store := db.NewGdbmDb()
+ store := gdbmdb.NewGdbmDb()
err := store.Connect(ctx, dbFile)
if err != nil {
panic(err)
@@ -46,7 +48,7 @@ func main() {
rs = rs.WithTemplateGetter(tg.GetTemplate)
rs = rs.WithCodeGetter(tg.GetCode)
- fsStore := db.NewFsDb()
+ fsStore := fsdb.NewFsDb()
fsStore.Connect(ctx, scriptDir)
rsf := resource.NewDbResource(fsStore)
rsf.WithOnly(db.DATATYPE_MENU)
diff --git a/examples/http/main.go b/examples/http/main.go
@@ -16,7 +16,7 @@ import (
"git.defalsify.org/vise.git/persist"
"git.defalsify.org/vise.git/resource"
"git.defalsify.org/vise.git/logging"
- "git.defalsify.org/vise.git/db"
+ fsdb "git.defalsify.org/vise.git/db/fs"
)
var (
@@ -77,7 +77,7 @@ type DefaultSessionHandler struct {
}
func NewDefaultSessionHandler(ctx context.Context, persistBase string, resourceBase string, rp RequestParser, outputSize uint32, cacheSize uint32, flagCount uint32) *DefaultSessionHandler {
- store := db.NewFsDb()
+ store := fsdb.NewFsDb()
err := store.Connect(ctx, resourceBase)
if err != nil {
panic(err)
@@ -103,7 +103,7 @@ func(f *DefaultSessionHandler) GetEngine(ctx context.Context, sessionId string)
cfg.SessionId = sessionId
persistPath := path.Join(f.peBase, sessionId)
- store := db.NewFsDb()
+ store := fsdb.NewFsDb()
err := store.Connect(ctx, persistPath)
if err != nil {
return nil, err
diff --git a/examples/intro/main.go b/examples/intro/main.go
@@ -15,7 +15,7 @@ import (
"git.defalsify.org/vise.git/engine"
"git.defalsify.org/vise.git/resource"
"git.defalsify.org/vise.git/state"
- "git.defalsify.org/vise.git/db"
+ fsdb "git.defalsify.org/vise.git/db/fs"
)
const (
@@ -34,7 +34,7 @@ type introResource struct {
}
func newintroResource(ctx context.Context) introResource {
- store := db.NewFsDb()
+ store := fsdb.NewFsDb()
err := store.Connect(ctx, scriptDir)
if err != nil {
panic(err)
diff --git a/examples/languages/main.go b/examples/languages/main.go
@@ -16,7 +16,7 @@ import (
"git.defalsify.org/vise.git/engine"
"git.defalsify.org/vise.git/resource"
"git.defalsify.org/vise.git/state"
- "git.defalsify.org/vise.git/db"
+ fsdb "git.defalsify.org/vise.git/db/fs"
"git.defalsify.org/vise.git/logging"
)
@@ -91,7 +91,7 @@ func main() {
st := state.NewState(1)
state.FlagDebugger.Register(USERFLAG_FLIP, "FLIP")
ctx := context.Background()
- rsStore := db.NewFsDb()
+ rsStore := fsdb.NewFsDb()
err := rsStore.Connect(ctx, scriptDir)
if err != nil {
panic(err)
@@ -105,7 +105,7 @@ func main() {
}
dp := path.Join(scriptDir, ".state")
- store := db.NewFsDb()
+ store := fsdb.NewFsDb()
err = store.Connect(ctx, dp)
if err != nil {
logg.ErrorCtxf(ctx, "db connect fail", "err", err)
diff --git a/examples/longmenu/main.go b/examples/longmenu/main.go
@@ -11,7 +11,7 @@ import (
testdataloader "github.com/peteole/testdata-loader"
"git.defalsify.org/vise.git/engine"
- "git.defalsify.org/vise.git/db"
+ fsdb "git.defalsify.org/vise.git/db/fs"
)
var (
baseDir = testdataloader.GetBasePath()
@@ -34,7 +34,7 @@ func main() {
ctx := context.Background()
dp := path.Join(scriptDir, ".state")
- store := db.NewFsDb()
+ store := fsdb.NewFsDb()
err := store.Connect(ctx, dp)
if err != nil {
fmt.Fprintf(os.Stderr, "db connect error: %v", err)
diff --git a/examples/pincheck/main.go b/examples/pincheck/main.go
@@ -16,7 +16,7 @@ import (
"git.defalsify.org/vise.git/resource"
"git.defalsify.org/vise.git/state"
"git.defalsify.org/vise.git/logging"
- "git.defalsify.org/vise.git/db"
+ fsdb "git.defalsify.org/vise.git/db/fs"
)
const (
@@ -77,7 +77,7 @@ func main() {
st.UseDebug()
state.FlagDebugger.Register(USERFLAG_VALIDPIN, "VALIDPIN")
state.FlagDebugger.Register(USERFLAG_QUERYPIN, "QUERYPIN")
- store := db.NewFsDb()
+ store := fsdb.NewFsDb()
err := store.Connect(ctx, scriptDir)
if err != nil {
panic(err)
diff --git a/examples/preprocessor/main.go b/examples/preprocessor/main.go
@@ -15,7 +15,7 @@ import (
"git.defalsify.org/vise.git/engine"
"git.defalsify.org/vise.git/resource"
"git.defalsify.org/vise.git/state"
- "git.defalsify.org/vise.git/db"
+ fsdb "git.defalsify.org/vise.git/db/fs"
)
@@ -73,7 +73,7 @@ func main() {
ctx := context.Background()
st := state.NewState(5)
st.UseDebug()
- store := db.NewFsDb()
+ store := fsdb.NewFsDb()
err := store.Connect(ctx, scriptDir)
if err != nil {
panic(err)
diff --git a/examples/profile/main.go b/examples/profile/main.go
@@ -17,6 +17,7 @@ import (
"git.defalsify.org/vise.git/resource"
"git.defalsify.org/vise.git/state"
"git.defalsify.org/vise.git/db"
+ fsdb "git.defalsify.org/vise.git/db/fs"
)
const (
@@ -100,7 +101,7 @@ func main() {
ctx := context.Background()
st := state.NewState(3)
- store := db.NewFsDb()
+ store := fsdb.NewFsDb()
err := store.Connect(ctx, scriptDir)
if err != nil {
panic(err)
diff --git a/examples/quit/main.go b/examples/quit/main.go
@@ -13,7 +13,7 @@ import (
"git.defalsify.org/vise.git/engine"
"git.defalsify.org/vise.git/resource"
"git.defalsify.org/vise.git/state"
- "git.defalsify.org/vise.git/db"
+ fsdb "git.defalsify.org/vise.git/db/fs"
)
var (
@@ -33,7 +33,7 @@ func main() {
ca := cache.NewCache()
ctx := context.Background()
- store := db.NewFsDb()
+ store := fsdb.NewFsDb()
err := store.Connect(ctx, scriptDir)
if err != nil {
panic(err)
diff --git a/examples/reuse/main.go b/examples/reuse/main.go
@@ -12,8 +12,8 @@ import (
"git.defalsify.org/vise.git/cache"
"git.defalsify.org/vise.git/engine"
"git.defalsify.org/vise.git/resource"
- "git.defalsify.org/vise.git/db"
"git.defalsify.org/vise.git/state"
+ fsdb "git.defalsify.org/vise.git/db/fs"
)
const (
@@ -38,7 +38,7 @@ func main() {
ctx := context.Background()
st := state.NewState(0)
- store := db.NewFsDb()
+ store := fsdb.NewFsDb()
err := store.Connect(ctx, scriptDir)
if err != nil {
panic(err)
diff --git a/examples/session/main.go b/examples/session/main.go
@@ -16,7 +16,7 @@ import (
"git.defalsify.org/vise.git/resource"
"git.defalsify.org/vise.git/state"
"git.defalsify.org/vise.git/logging"
- "git.defalsify.org/vise.git/db"
+ fsdb "git.defalsify.org/vise.git/db/fs"
)
var (
@@ -66,7 +66,7 @@ func main() {
ctx := context.Background()
st := state.NewState(0)
st.UseDebug()
- store := db.NewFsDb()
+ store := fsdb.NewFsDb()
err := store.Connect(ctx, scriptDir)
if err != nil {
panic(err)
diff --git a/examples/state/main.go b/examples/state/main.go
@@ -14,7 +14,7 @@ import (
"git.defalsify.org/vise.git/resource"
"git.defalsify.org/vise.git/state"
"git.defalsify.org/vise.git/logging"
- "git.defalsify.org/vise.git/db"
+ fsdb "git.defalsify.org/vise.git/db/fs"
)
const (
@@ -75,7 +75,7 @@ func main() {
ctx := context.Background()
st := state.NewState(3)
st.UseDebug()
- store := db.NewFsDb()
+ store := fsdb.NewFsDb()
err := store.Connect(ctx, scriptDir)
if err != nil {
panic(err)
diff --git a/examples/state_passive/main.go b/examples/state_passive/main.go
@@ -14,8 +14,8 @@ import (
"git.defalsify.org/vise.git/engine"
"git.defalsify.org/vise.git/cache"
"git.defalsify.org/vise.git/persist"
- "git.defalsify.org/vise.git/db"
"git.defalsify.org/vise.git/logging"
+ fsdb "git.defalsify.org/vise.git/db/fs"
)
const (
@@ -90,7 +90,7 @@ func main() {
ctx := context.Background()
st := state.NewState(4)
- rsStore := db.NewFsDb()
+ rsStore := fsdb.NewFsDb()
err := rsStore.Connect(ctx, dir)
if err != nil {
panic(err)
@@ -103,7 +103,7 @@ func main() {
}
dp := path.Join(dir, ".state")
- store := db.NewFsDb()
+ store := fsdb.NewFsDb()
err = store.Connect(ctx, dp)
if err != nil {
fmt.Fprintf(os.Stderr, "db connect fail: %s", err)
diff --git a/examples/validate/main.go b/examples/validate/main.go
@@ -14,7 +14,7 @@ import (
"git.defalsify.org/vise.git/engine"
"git.defalsify.org/vise.git/resource"
"git.defalsify.org/vise.git/state"
- "git.defalsify.org/vise.git/db"
+ fsdb "git.defalsify.org/vise.git/db/fs"
)
var (
@@ -60,7 +60,7 @@ func main() {
ctx := context.Background()
ctx = context.WithValue(ctx, "SessionId", sessionId)
st := state.NewState(1)
- store := db.NewFsDb()
+ store := fsdb.NewFsDb()
err := store.Connect(ctx, scriptDir)
if err != nil {
panic(err)
diff --git a/internal/resourcetest/util.go b/internal/resourcetest/util.go
@@ -4,6 +4,7 @@ import (
"context"
"git.defalsify.org/vise.git/resource"
+ "git.defalsify.org/vise.git/db/mem"
"git.defalsify.org/vise.git/db"
)
@@ -29,13 +30,13 @@ func newTestResource(path string) *TestResource {
ctx := context.Background()
if path == "" {
- mem := db.NewMemDb()
+ mem := mem.NewMemDb()
mem.SetLock(db.DATATYPE_TEMPLATE, false)
mem.SetLock(db.DATATYPE_BIN, false)
mem.SetLock(db.DATATYPE_MENU, false)
store = mem
} else {
- fs := db.NewMemDb()
+ fs := mem.NewMemDb()
fs.SetLock(db.DATATYPE_TEMPLATE, false)
fs.SetLock(db.DATATYPE_BIN, false)
fs.SetLock(db.DATATYPE_MENU, false)
diff --git a/persist/fs_test.go b/persist/fs_test.go
@@ -9,7 +9,7 @@ import (
"git.defalsify.org/vise.git/cache"
"git.defalsify.org/vise.git/state"
"git.defalsify.org/vise.git/vm"
- "git.defalsify.org/vise.git/db"
+ "git.defalsify.org/vise.git/db/mem"
)
func TestSerializeState(t *testing.T) {
@@ -29,7 +29,7 @@ func TestSerializeState(t *testing.T) {
ca.Add("blinky", "clyde", 42)
ctx := context.Background()
- store := db.NewMemDb()
+ store := mem.NewMemDb()
store.Connect(ctx, "")
pr := NewPersister(store).WithContext(context.Background()).WithSession("xyzzy").WithContent(&st, ca)
v, err := pr.Serialize()
@@ -81,7 +81,7 @@ func TestSaveLoad(t *testing.T) {
ca.Add("blinky", "clyde", 42)
ctx := context.Background()
- store := db.NewMemDb()
+ store := mem.NewMemDb()
store.Connect(ctx, "")
pr := NewPersister(store).WithContent(&st, ca)
err := pr.Save("xyzzy")
@@ -122,7 +122,7 @@ func TestSaveLoadFlags(t *testing.T) {
st.SetFlag(8)
ca := cache.NewCache()
- store := db.NewMemDb()
+ store := mem.NewMemDb()
store.Connect(ctx, "")
pr := NewPersister(store).WithContent(&st, ca)
err := pr.Save("xyzzy")
diff --git a/persist/persist_test.go b/persist/persist_test.go
@@ -4,7 +4,7 @@ import (
"context"
"testing"
- "git.defalsify.org/vise.git/db"
+ "git.defalsify.org/vise.git/db/mem"
"git.defalsify.org/vise.git/state"
"git.defalsify.org/vise.git/cache"
)
@@ -14,7 +14,7 @@ func TestInvalidateState(t *testing.T) {
ca := cache.NewCache()
ctx := context.Background()
- store := db.NewMemDb()
+ store := mem.NewMemDb()
store.Connect(ctx, "")
pr := NewPersister(store).WithSession("xyzzy").WithContent(&st, ca)
err := pr.Save("foo")
@@ -36,7 +36,7 @@ func TestInvalidateCache(t *testing.T) {
ca := cache.NewCache()
ctx := context.Background()
- store := db.NewMemDb()
+ store := mem.NewMemDb()
store.Connect(ctx, "")
pr := NewPersister(store).WithSession("xyzzy").WithContent(&st, ca)
err := pr.Save("foo")
@@ -58,7 +58,7 @@ func TestInvalidateAll(t *testing.T) {
ca := cache.NewCache()
ctx := context.Background()
- store := db.NewMemDb()
+ store := mem.NewMemDb()
store.Connect(ctx, "")
pr := NewPersister(store).WithSession("xyzzy").WithContent(&st, ca)
err := pr.Save("foo")
diff --git a/resource/db_test.go b/resource/db_test.go
@@ -6,12 +6,13 @@ import (
"testing"
"git.defalsify.org/vise.git/db"
+ "git.defalsify.org/vise.git/db/mem"
)
func TestDb(t *testing.T) {
var rsifc Resource
ctx := context.Background()
- store := db.NewMemDb()
+ store := mem.NewMemDb()
store.Connect(ctx, "")
tg := NewDbResource(store)
tg.Without(db.DATATYPE_BIN)
diff --git a/testdata/testdata.go b/testdata/testdata.go
@@ -7,13 +7,14 @@ import (
"os"
"git.defalsify.org/vise.git/db"
+ fsdb "git.defalsify.org/vise.git/db/fs"
"git.defalsify.org/vise.git/resource"
"git.defalsify.org/vise.git/logging"
)
var (
ctx = context.Background()
- store = db.NewFsDb()
+ store = fsdb.NewFsDb()
out = outNew
logg = logging.NewVanilla().WithDomain("testdata")
)
@@ -56,7 +57,7 @@ func generate() error {
if err != nil {
return err
}
- store = db.NewFsDb()
+ store = fsdb.NewFsDb()
store.Connect(ctx, DataDir)
store.SetLock(db.DATATYPE_TEMPLATE, false)
store.SetLock(db.DATATYPE_BIN, false)