Reinstate resource-dir switch

This commit is contained in:
lash 2025-01-22 09:42:39 +00:00
parent 49335a290f
commit 1909b60bf4
Signed by: lash
GPG Key ID: 21D2E7BB88C2A746
9 changed files with 54 additions and 24 deletions

View File

@ -44,11 +44,13 @@ func main() {
var err error var err error
var gettextDir string var gettextDir string
var langs args.LangVar var langs args.LangVar
var resourceDir string
flag.BoolVar(&engineDebug, "d", false, "use engine debug output") flag.BoolVar(&engineDebug, "d", false, "use engine debug output")
flag.StringVar(override.DbConn, "c", "?", "default connection string (replaces all unspecified strings)") flag.StringVar(override.DbConn, "c", "?", "default connection string (replaces all unspecified strings)")
flag.StringVar(override.ResourceConn, "resource", "?", "resource connection string")
flag.StringVar(override.UserConn, "userdata", "?", "userdata store connection string") flag.StringVar(override.UserConn, "userdata", "?", "userdata store connection string")
flag.StringVar(override.ResourceConn, "resource", "?", "resource data directory")
flag.StringVar(&resourceDir, "resource-dir", "", "resource data directory. If set, overrides --resource to create a non-binary fsdb for the given path.")
flag.StringVar(override.StateConn, "state", "?", "state store connection string") flag.StringVar(override.StateConn, "state", "?", "state store connection string")
flag.UintVar(&size, "s", 160, "max size of output") flag.UintVar(&size, "s", 160, "max size of output")
flag.StringVar(&host, "h", config.Host(), "http host") flag.StringVar(&host, "h", config.Host(), "http host")
@ -57,6 +59,10 @@ func main() {
flag.Var(&langs, "language", "add symbol resolution for language") flag.Var(&langs, "language", "add symbol resolution for language")
flag.Parse() flag.Parse()
if resourceDir != "" {
*override.ResourceConn = resourceDir
override.ResourceConnMode = storage.DBMODE_TEXT
}
config.Apply(override) config.Apply(override)
conns, err := config.GetConns() conns, err := config.GetConns()
if err != nil { if err != nil {

View File

@ -53,10 +53,12 @@ func main() {
var err error var err error
var gettextDir string var gettextDir string
var langs args.LangVar var langs args.LangVar
var resourceDir string
flag.StringVar(&sessionId, "session-id", "075xx2123", "session id") flag.StringVar(&sessionId, "session-id", "075xx2123", "session id")
flag.StringVar(override.DbConn, "c", "?", "default connection string (replaces all unspecified strings)") flag.StringVar(override.DbConn, "c", "?", "default connection string (replaces all unspecified strings)")
flag.StringVar(override.ResourceConn, "resource", "?", "resource connection string") flag.StringVar(override.ResourceConn, "resource", "?", "resource data directory")
flag.StringVar(&resourceDir, "resource-dir", "", "resource data directory. If set, overrides --resource to create a non-binary fsdb for the given path.")
flag.StringVar(override.UserConn, "userdata", "?", "userdata store connection string") flag.StringVar(override.UserConn, "userdata", "?", "userdata store connection string")
flag.StringVar(override.StateConn, "state", "?", "state store connection string") flag.StringVar(override.StateConn, "state", "?", "state store connection string")
@ -68,6 +70,10 @@ func main() {
flag.Var(&langs, "language", "add symbol resolution for language") flag.Var(&langs, "language", "add symbol resolution for language")
flag.Parse() flag.Parse()
if resourceDir != "" {
*override.ResourceConn = resourceDir
override.ResourceConnMode = storage.DBMODE_TEXT
}
config.Apply(override) config.Apply(override)
conns, err := config.GetConns() conns, err := config.GetConns()
if err != nil { if err != nil {

View File

@ -43,10 +43,12 @@ func main() {
var err error var err error
var gettextDir string var gettextDir string
var langs args.LangVar var langs args.LangVar
var resourceDir string
flag.StringVar(override.DbConn, "c", "?", "default connection string (replaces all unspecified strings)") flag.StringVar(override.DbConn, "c", "?", "default connection string (replaces all unspecified strings)")
flag.StringVar(override.ResourceConn, "resource", "?", "resource connection string")
flag.StringVar(override.UserConn, "userdata", "?", "userdata store connection string") flag.StringVar(override.UserConn, "userdata", "?", "userdata store connection string")
flag.StringVar(override.ResourceConn, "resource", "?", "resource data directory")
flag.StringVar(&resourceDir, "resource-dir", "", "resource data directory. If set, overrides --resource to create a non-binary fsdb for the given path.")
flag.StringVar(override.StateConn, "state", "?", "state store connection string") flag.StringVar(override.StateConn, "state", "?", "state store connection string")
flag.BoolVar(&engineDebug, "d", false, "use engine debug output") flag.BoolVar(&engineDebug, "d", false, "use engine debug output")
@ -57,6 +59,10 @@ func main() {
flag.Var(&langs, "language", "add symbol resolution for language") flag.Var(&langs, "language", "add symbol resolution for language")
flag.Parse() flag.Parse()
if resourceDir != "" {
*override.ResourceConn = resourceDir
override.ResourceConnMode = storage.DBMODE_TEXT
}
config.Apply(override) config.Apply(override)
conns, err := config.GetConns() conns, err := config.GetConns()
if err != nil { if err != nil {

View File

@ -36,10 +36,12 @@ func main() {
var err error var err error
var gettextDir string var gettextDir string
var langs args.LangVar var langs args.LangVar
var resourceDir string
flag.StringVar(&sessionId, "session-id", "075xx2123", "session id") flag.StringVar(&sessionId, "session-id", "075xx2123", "session id")
flag.StringVar(override.DbConn, "c", "?", "default connection string (replaces all unspecified strings)") flag.StringVar(override.DbConn, "c", "?", "default connection string (replaces all unspecified strings)")
flag.StringVar(override.ResourceConn, "resource", "?", "resource connection string") flag.StringVar(override.ResourceConn, "resource", "?", "resource data directory")
flag.StringVar(&resourceDir, "resource-dir", "", "resource data directory. If set, overrides --resource to create a non-binary fsdb for the given path.")
flag.StringVar(override.UserConn, "userdata", "?", "userdata store connection string") flag.StringVar(override.UserConn, "userdata", "?", "userdata store connection string")
flag.StringVar(override.StateConn, "state", "?", "state store connection string") flag.StringVar(override.StateConn, "state", "?", "state store connection string")
flag.BoolVar(&engineDebug, "d", false, "use engine debug output") flag.BoolVar(&engineDebug, "d", false, "use engine debug output")
@ -48,6 +50,10 @@ func main() {
flag.Var(&langs, "language", "add symbol resolution for language") flag.Var(&langs, "language", "add symbol resolution for language")
flag.Parse() flag.Parse()
if resourceDir != "" {
*override.ResourceConn = resourceDir
override.ResourceConnMode = storage.DBMODE_TEXT
}
config.Apply(override) config.Apply(override)
conns, err := config.GetConns() conns, err := config.GetConns()
if err != nil { if err != nil {

View File

@ -4,19 +4,12 @@ import (
viseconfig "git.grassecon.net/grassrootseconomics/visedriver/config" viseconfig "git.grassecon.net/grassrootseconomics/visedriver/config"
) )
type Override struct { func NewOverride() *viseconfig.Override {
DbConn *string
StateConn *string
ResourceConn *string
UserConn *string
}
func NewOverride() *Override {
var a string var a string
var b string var b string
var c string var c string
var d string var d string
o := &Override{ o := &viseconfig.Override{
DbConn: &a, DbConn: &a,
StateConn: &b, StateConn: &b,
ResourceConn: &c, ResourceConn: &c,
@ -25,7 +18,7 @@ func NewOverride() *Override {
return o return o
} }
func Apply(o *Override) error { func Apply(o *viseconfig.Override) error {
viseconfig.ApplyConn(o.DbConn, o.StateConn, o.ResourceConn, o.UserConn) viseconfig.ApplyConn(o)
return nil return nil
} }

View File

@ -23,17 +23,24 @@ var (
func main() { func main() {
config.LoadConfig() config.LoadConfig()
override := config.NewOverride()
var sessionId string var sessionId string
var override config.Override var resourceDir string
flag.StringVar(&sessionId, "session-id", "075xx2123", "session id") flag.StringVar(&sessionId, "session-id", "075xx2123", "session id")
flag.StringVar(override.DbConn, "c", "?", "default connection string (replaces all unspecified strings)") flag.StringVar(override.DbConn, "c", "?", "default connection string (replaces all unspecified strings)")
flag.StringVar(override.ResourceConn, "resource", "?", "resource connection string") flag.StringVar(override.ResourceConn, "resource", "?", "resource data directory")
flag.StringVar(&resourceDir, "resource-dir", "", "resource data directory. If set, overrides --resource to create a non-binary fsdb for the given path.")
flag.StringVar(override.UserConn, "userdata", "?", "userdata store connection string") flag.StringVar(override.UserConn, "userdata", "?", "userdata store connection string")
flag.StringVar(override.StateConn, "state", "?", "state store connection string") flag.StringVar(override.StateConn, "state", "?", "state store connection string")
flag.Parse() flag.Parse()
config.Apply(&override) if resourceDir != "" {
*override.ResourceConn = resourceDir
override.ResourceConnMode = storage.DBMODE_TEXT
}
config.Apply(override)
conns, err := config.GetConns() conns, err := config.GetConns()
if err != nil { if err != nil {
fmt.Fprintf(os.Stderr, "conn specification error: %v\n", err) fmt.Fprintf(os.Stderr, "conn specification error: %v\n", err)

View File

@ -32,22 +32,28 @@ func formatItem(k []byte, v []byte, sessionId string) (string, error) {
func main() { func main() {
config.LoadConfig() config.LoadConfig()
var override config.Override override := config.NewOverride()
var sessionId string var sessionId string
var database string var database string
var engineDebug bool var engineDebug bool
var err error var err error
var first bool var first bool
var resourceDir string
flag.StringVar(&sessionId, "session-id", "075xx2123", "session id") flag.StringVar(&sessionId, "session-id", "075xx2123", "session id")
flag.StringVar(override.DbConn, "c", "?", "default connection string (replaces all unspecified strings)") flag.StringVar(override.DbConn, "c", "?", "default connection string (replaces all unspecified strings)")
flag.StringVar(override.ResourceConn, "resource", "?", "resource connection string") flag.StringVar(override.ResourceConn, "resource", "?", "resource data directory")
flag.StringVar(&resourceDir, "resource-dir", "", "resource data directory. If set, overrides --resource to create a non-binary fsdb for the given path.")
flag.StringVar(override.UserConn, "userdata", "?", "userdata store connection string") flag.StringVar(override.UserConn, "userdata", "?", "userdata store connection string")
flag.StringVar(override.StateConn, "state", "?", "state store connection string") flag.StringVar(override.StateConn, "state", "?", "state store connection string")
flag.BoolVar(&engineDebug, "d", false, "use engine debug output") flag.BoolVar(&engineDebug, "d", false, "use engine debug output")
flag.Parse() flag.Parse()
config.Apply(&override) if resourceDir != "" {
*override.ResourceConn = resourceDir
override.ResourceConnMode = storage.DBMODE_TEXT
}
config.Apply(override)
conns, err := config.GetConns() conns, err := config.GetConns()
if err != nil { if err != nil {
fmt.Fprintf(os.Stderr, "conn specification error: %v\n", err) fmt.Fprintf(os.Stderr, "conn specification error: %v\n", err)

2
go.mod
View File

@ -6,7 +6,7 @@ require (
git.defalsify.org/vise.git v0.2.3-0.20250120121301-10739fb4a8c9 git.defalsify.org/vise.git v0.2.3-0.20250120121301-10739fb4a8c9
git.grassecon.net/grassrootseconomics/common v0.0.0-20250121134736-ba8cbbccea7d git.grassecon.net/grassrootseconomics/common v0.0.0-20250121134736-ba8cbbccea7d
git.grassecon.net/grassrootseconomics/sarafu-api v0.0.0-20250121135150-e0b539809805 git.grassecon.net/grassrootseconomics/sarafu-api v0.0.0-20250121135150-e0b539809805
git.grassecon.net/grassrootseconomics/visedriver v0.8.0-beta.10.0.20250121134912-f7d31e4e8162 git.grassecon.net/grassrootseconomics/visedriver v0.8.0-beta.10.0.20250122093711-8530c450741a
git.grassecon.net/grassrootseconomics/visedriver-africastalking v0.0.0-20250121135340-ca97e23e8c84 git.grassecon.net/grassrootseconomics/visedriver-africastalking v0.0.0-20250121135340-ca97e23e8c84
github.com/alecthomas/assert/v2 v2.2.2 github.com/alecthomas/assert/v2 v2.2.2
github.com/gofrs/uuid v4.4.0+incompatible github.com/gofrs/uuid v4.4.0+incompatible

4
go.sum
View File

@ -4,8 +4,8 @@ git.grassecon.net/grassrootseconomics/common v0.0.0-20250121134736-ba8cbbccea7d
git.grassecon.net/grassrootseconomics/common v0.0.0-20250121134736-ba8cbbccea7d/go.mod h1:wgQJZGIS6QuNLHqDhcsvehsbn5PvgV7aziRebMnJi60= git.grassecon.net/grassrootseconomics/common v0.0.0-20250121134736-ba8cbbccea7d/go.mod h1:wgQJZGIS6QuNLHqDhcsvehsbn5PvgV7aziRebMnJi60=
git.grassecon.net/grassrootseconomics/sarafu-api v0.0.0-20250121135150-e0b539809805 h1:deGnqf4YCsbxhXgjFEjYjTUCvciLEmI26T9IysRsQXY= git.grassecon.net/grassrootseconomics/sarafu-api v0.0.0-20250121135150-e0b539809805 h1:deGnqf4YCsbxhXgjFEjYjTUCvciLEmI26T9IysRsQXY=
git.grassecon.net/grassrootseconomics/sarafu-api v0.0.0-20250121135150-e0b539809805/go.mod h1:9bc3d//Qqm11hz7GYRdQc1Uan+0GJIOpvRBbv8cHMu8= git.grassecon.net/grassrootseconomics/sarafu-api v0.0.0-20250121135150-e0b539809805/go.mod h1:9bc3d//Qqm11hz7GYRdQc1Uan+0GJIOpvRBbv8cHMu8=
git.grassecon.net/grassrootseconomics/visedriver v0.8.0-beta.10.0.20250121134912-f7d31e4e8162 h1:NaPbgGQ1Nb+yYF+Qj1LSagpjYeDcSXST8iZwONg4afY= git.grassecon.net/grassrootseconomics/visedriver v0.8.0-beta.10.0.20250122093711-8530c450741a h1:g0epqAJvHdOvzdGNfH0ZmZ6QKsbcybOroLnYi78ZnDo=
git.grassecon.net/grassrootseconomics/visedriver v0.8.0-beta.10.0.20250121134912-f7d31e4e8162/go.mod h1:pjKp9L/ZsWW3kMB0UoIl1yv9TBIuU33mn9Aghxp7vGk= git.grassecon.net/grassrootseconomics/visedriver v0.8.0-beta.10.0.20250122093711-8530c450741a/go.mod h1:pjKp9L/ZsWW3kMB0UoIl1yv9TBIuU33mn9Aghxp7vGk=
git.grassecon.net/grassrootseconomics/visedriver-africastalking v0.0.0-20250121135340-ca97e23e8c84 h1:VoBmqsjlRdz+IPbtKsAkc1IrMepjR+QlesZT31Jokrk= git.grassecon.net/grassrootseconomics/visedriver-africastalking v0.0.0-20250121135340-ca97e23e8c84 h1:VoBmqsjlRdz+IPbtKsAkc1IrMepjR+QlesZT31Jokrk=
git.grassecon.net/grassrootseconomics/visedriver-africastalking v0.0.0-20250121135340-ca97e23e8c84/go.mod h1:DpibtYpnT3nG4Kn556hRAkdu4+CtiI/6MbnQHal51mQ= git.grassecon.net/grassrootseconomics/visedriver-africastalking v0.0.0-20250121135340-ca97e23e8c84/go.mod h1:DpibtYpnT3nG4Kn556hRAkdu4+CtiI/6MbnQHal51mQ=
github.com/alecthomas/assert/v2 v2.2.2 h1:Z/iVC0xZfWTaFNE6bA3z07T86hd45Xe2eLt6WVy2bbk= github.com/alecthomas/assert/v2 v2.2.2 h1:Z/iVC0xZfWTaFNE6bA3z07T86hd45Xe2eLt6WVy2bbk=