forked from urdt/ussd
Refactor to use conndata as menustorageservice conn arg
This commit is contained in:
@@ -7,7 +7,6 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
|
||||
"git.defalsify.org/vise.git/logging"
|
||||
"git.grassecon.net/urdt/ussd/config"
|
||||
@@ -36,19 +35,20 @@ func main() {
|
||||
var err error
|
||||
|
||||
flag.StringVar(&sessionId, "session-id", "075xx2123", "session id")
|
||||
flag.StringVar(&connStr, "c", ".", "connection string")
|
||||
flag.StringVar(&connStr, "c", "", "connection string")
|
||||
flag.BoolVar(&engineDebug, "d", false, "use engine debug output")
|
||||
flag.Parse()
|
||||
|
||||
if connStr == "." {
|
||||
connStr, err = filepath.Abs(".state/state.gdbm")
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "auto connstr generate error: %v", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
if connStr != "" {
|
||||
connStr = config.DbConn
|
||||
}
|
||||
connData, err := storage.ToConnData(config.DbConn)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "connstr err: %v", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
logg.Infof("start command", "connstr", connStr)
|
||||
logg.Infof("start command", "conn", connData)
|
||||
|
||||
ctx := context.Background()
|
||||
ctx = context.WithValue(ctx, "SessionId", sessionId)
|
||||
@@ -56,12 +56,8 @@ func main() {
|
||||
|
||||
resourceDir := scriptDir
|
||||
menuStorageService := storage.NewMenuStorageService(resourceDir)
|
||||
err = menuStorageService.SetConn(connStr)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "connection string error: %v", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
menuStorageService = menuStorageService.WithConn(connData)
|
||||
|
||||
store, err := menuStorageService.GetUserdataDb(ctx)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, err.Error())
|
||||
|
||||
Reference in New Issue
Block a user