diff --git a/config/config.go b/config/config.go index 3722234..8a1c942 100644 --- a/config/config.go +++ b/config/config.go @@ -26,13 +26,13 @@ var ( ) type Override struct { - DbConn *string + DbConn string DbConnMode storage.DbMode - StateConn *string + StateConn string StateConnMode storage.DbMode - ResourceConn *string + ResourceConn string ResourceConnMode storage.DbMode - UserConn *string + UserConn string UserConnMode storage.DbMode } @@ -63,18 +63,21 @@ func setConn() error { } func ApplyConn(override *Override) { - if override.DbConn != nil { - dbConn = *override.DbConn + if override.DbConn != "?" { + dbConn = override.DbConn + stateDbConn = override.StateConn + resourceDbConn = override.ResourceConn + userDbConn = override.UserConn } dbConnMode = override.DbConnMode - if override.StateConn != nil { - stateDbConn = *override.StateConn + if override.StateConn != "?" { + stateDbConn = override.StateConn } - if override.ResourceConn != nil { - resourceDbConn = *override.ResourceConn + if override.ResourceConn != "?" { + resourceDbConn = override.ResourceConn } - if override.UserConn != nil { - userDbConn = *override.UserConn + if override.UserConn != "?" { + userDbConn = override.UserConn } if dbConn == "?" { @@ -94,6 +97,10 @@ func ApplyConn(override *Override) { userDbConnMode = dbConnMode } + logg.Debugf("conns", "conn", dbConn, "user", userDbConn) + if override.DbConnMode != storage.DBMODE_ANY { + dbConnMode = override.DbConnMode + } if override.StateConnMode != storage.DBMODE_ANY { stateDbConnMode = override.StateConnMode } diff --git a/storage/storage_service.go b/storage/storage_service.go index ac113fe..4f18702 100644 --- a/storage/storage_service.go +++ b/storage/storage_service.go @@ -169,7 +169,9 @@ func ensureSchemaExists(ctx context.Context, conn ConnData) error { func applySession(ctx context.Context, store db.Db) error { sessionId, ok := ctx.Value("SessionId").(string) if !ok { - return fmt.Errorf("missing session to apply to store: %v", store) + logg.DebugCtxf(ctx, "missing session to apply", "store", store) + return nil + //return fmt.Errorf("missing session to apply to store: %v", store) } store.SetSession(sessionId) return nil @@ -184,7 +186,6 @@ func (ms *MenuStorageService) GetPersister(ctx context.Context) (*persist.Persis if err != nil { return nil, err } - pr := persist.NewPersister(stateStore) logg.TraceCtxf(ctx, "menu storage service", "persist", pr, "store", stateStore) return pr, nil @@ -195,7 +196,6 @@ func (ms *MenuStorageService) GetUserdataDb(ctx context.Context) (db.Db, error) if err != nil { return nil, err } - err = applySession(ctx, userStore) if err != nil { return nil, err