From adbfab3964bdedb1f888f0351c9c3f74c40471aa Mon Sep 17 00:00:00 2001 From: lash Date: Tue, 14 Jan 2025 18:57:04 +0000 Subject: [PATCH] Enable conndata fs, mem --- storage/parse.go | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/storage/parse.go b/storage/parse.go index 7fbded7..3b7850f 100644 --- a/storage/parse.go +++ b/storage/parse.go @@ -9,6 +9,7 @@ import ( const ( DBTYPE_NONE = iota DBTYPE_MEM + DBTYPE_FS DBTYPE_GDBM DBTYPE_POSTGRES ) @@ -54,6 +55,18 @@ func probePostgres(s string) (string, string, bool) { } func probeGdbm(s string) (string, string, bool) { + domain := "public" + v, err := url.Parse(s) + if err != nil { + return "", "", false + } + if v.Scheme != "gdbm" { + return "", "", false + } + return s, domain, true +} + +func probeFs(s string) (string, string, bool) { if !path.IsAbs(s) { return "", "", false } @@ -61,6 +74,13 @@ func probeGdbm(s string) (string, string, bool) { return s, "", true } +func probeMem(s string) (string, string, bool) { + if s != "" { + return "", "", false + } + return "", "", true +} + func ToConnData(connStr string) (ConnData, error) { var o ConnData @@ -83,5 +103,18 @@ func ToConnData(connStr string) (ConnData, error) { return o, nil } + v, _, ok = probeFs(connStr) + if ok { + o.typ = DBTYPE_FS + o.str = v + return o, nil + } + + v, _, ok = probeMem(connStr) + if ok { + o.typ = DBTYPE_MEM + return o, nil + } + return o, fmt.Errorf("invalid connection string: %s", connStr) }