From 4cdd8a1082acb5497088c4cb35e1d96fc563516b Mon Sep 17 00:00:00 2001 From: lash Date: Mon, 20 Jan 2025 11:03:31 +0000 Subject: [PATCH] Update to fit new menuhandler signatures --- cmd/main.go | 19 ++++++++++--------- config/config.go | 11 +++++++---- event/nats/nats_test.go | 2 +- event/token_test.go | 4 ++-- 4 files changed, 20 insertions(+), 16 deletions(-) diff --git a/cmd/main.go b/cmd/main.go index 3fa5fe8..7f6ddd5 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -23,25 +23,26 @@ var ( func main() { config.LoadConfig() - var connStr string + override := config.NewOverride() - flag.StringVar(&connStr, "c", "", "connection string") + 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.StateConn, "state", "?", "state store connection string") flag.Parse() - if connStr == "" { - connStr = config.DbConn() - } - connData, err := storage.ToConnData(connStr) + config.Apply(&override) + conns, err := config.GetConns() if err != nil { - fmt.Fprintf(os.Stderr, "connstr err: %v", err) + fmt.Fprintf(os.Stderr, "conn specification error: %v\n", err) os.Exit(1) } - logg.Infof("start command", "conn", connData) + logg.Infof("start command", "conn", conns) ctx := context.Background() - menuStorageService := storage.NewMenuStorageService(connData, "") + menuStorageService := storage.NewMenuStorageService(conns) eu := viseevent.NewEventsUpdater(lookup.Api, menuStorageService) eh := eu.ToEventsHandler() diff --git a/config/config.go b/config/config.go index 31d02b6..9ea134d 100644 --- a/config/config.go +++ b/config/config.go @@ -3,12 +3,15 @@ package config import ( viseconfig "git.grassecon.net/grassrootseconomics/visedriver/config" apiconfig "git.grassecon.net/grassrootseconomics/sarafu-api/config" + "git.grassecon.net/grassrootseconomics/sarafu-vise/config" "git.grassecon.net/grassrootseconomics/visedriver/env" ) var ( JetstreamURL string JetstreamClientName string + Apply = config.Apply + GetConns = config.GetConns ) const ( @@ -30,10 +33,10 @@ func LoadConfig() error { return nil } -func DbConn() string { - return viseconfig.DbConn -} - func Language() string { return viseconfig.DefaultLanguage } + +func NewOverride() config.Override { + return config.Override{} +} diff --git a/event/nats/nats_test.go b/event/nats/nats_test.go index 6eac4f2..5c85a19 100644 --- a/event/nats/nats_test.go +++ b/event/nats/nats_test.go @@ -197,7 +197,7 @@ func TestHandleMsg(t *testing.T) { } - mh, err := application.NewMenuHandlers(nil, userStore, nil, nil, testutil.ReplaceSeparatorFunc) + mh, err := application.NewMenuHandlers(nil, userStore, nil, testutil.ReplaceSeparatorFunc) if err != nil { t.Fatal(err) } diff --git a/event/token_test.go b/event/token_test.go index 4d66364..9c28c15 100644 --- a/event/token_test.go +++ b/event/token_test.go @@ -136,7 +136,7 @@ func TestTokenTransfer(t *testing.T) { t.Fatal("no transaction data") } - mh, err := application.NewMenuHandlers(nil, userStore, nil, nil, testutil.ReplaceSeparatorFunc) + mh, err := application.NewMenuHandlers(nil, userStore, nil, testutil.ReplaceSeparatorFunc) if err != nil { t.Fatal(err) } @@ -246,7 +246,7 @@ func TestTokenMint(t *testing.T) { t.Fatal("no transaction data") } - mh, err := application.NewMenuHandlers(nil, userStore, nil, nil, testutil.ReplaceSeparatorFunc) + mh, err := application.NewMenuHandlers(nil, userStore, nil, testutil.ReplaceSeparatorFunc) if err != nil { t.Fatal(err) }