forked from grassrootseconomics/visedriver
Apply dbconn explicit to all conns by default
This commit is contained in:
parent
15ce29a1a4
commit
03d19283f6
@ -26,13 +26,13 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type Override struct {
|
type Override struct {
|
||||||
DbConn *string
|
DbConn string
|
||||||
DbConnMode storage.DbMode
|
DbConnMode storage.DbMode
|
||||||
StateConn *string
|
StateConn string
|
||||||
StateConnMode storage.DbMode
|
StateConnMode storage.DbMode
|
||||||
ResourceConn *string
|
ResourceConn string
|
||||||
ResourceConnMode storage.DbMode
|
ResourceConnMode storage.DbMode
|
||||||
UserConn *string
|
UserConn string
|
||||||
UserConnMode storage.DbMode
|
UserConnMode storage.DbMode
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,18 +63,21 @@ func setConn() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func ApplyConn(override *Override) {
|
func ApplyConn(override *Override) {
|
||||||
if override.DbConn != nil {
|
if override.DbConn != "?" {
|
||||||
dbConn = *override.DbConn
|
dbConn = override.DbConn
|
||||||
|
stateDbConn = override.StateConn
|
||||||
|
resourceDbConn = override.ResourceConn
|
||||||
|
userDbConn = override.UserConn
|
||||||
}
|
}
|
||||||
dbConnMode = override.DbConnMode
|
dbConnMode = override.DbConnMode
|
||||||
if override.StateConn != nil {
|
if override.StateConn != "?" {
|
||||||
stateDbConn = *override.StateConn
|
stateDbConn = override.StateConn
|
||||||
}
|
}
|
||||||
if override.ResourceConn != nil {
|
if override.ResourceConn != "?" {
|
||||||
resourceDbConn = *override.ResourceConn
|
resourceDbConn = override.ResourceConn
|
||||||
}
|
}
|
||||||
if override.UserConn != nil {
|
if override.UserConn != "?" {
|
||||||
userDbConn = *override.UserConn
|
userDbConn = override.UserConn
|
||||||
}
|
}
|
||||||
|
|
||||||
if dbConn == "?" {
|
if dbConn == "?" {
|
||||||
@ -94,6 +97,10 @@ func ApplyConn(override *Override) {
|
|||||||
userDbConnMode = dbConnMode
|
userDbConnMode = dbConnMode
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logg.Debugf("conns", "conn", dbConn, "user", userDbConn)
|
||||||
|
if override.DbConnMode != storage.DBMODE_ANY {
|
||||||
|
dbConnMode = override.DbConnMode
|
||||||
|
}
|
||||||
if override.StateConnMode != storage.DBMODE_ANY {
|
if override.StateConnMode != storage.DBMODE_ANY {
|
||||||
stateDbConnMode = override.StateConnMode
|
stateDbConnMode = override.StateConnMode
|
||||||
}
|
}
|
||||||
|
@ -169,7 +169,9 @@ func ensureSchemaExists(ctx context.Context, conn ConnData) error {
|
|||||||
func applySession(ctx context.Context, store db.Db) error {
|
func applySession(ctx context.Context, store db.Db) error {
|
||||||
sessionId, ok := ctx.Value("SessionId").(string)
|
sessionId, ok := ctx.Value("SessionId").(string)
|
||||||
if !ok {
|
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)
|
store.SetSession(sessionId)
|
||||||
return nil
|
return nil
|
||||||
@ -184,7 +186,6 @@ func (ms *MenuStorageService) GetPersister(ctx context.Context) (*persist.Persis
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
pr := persist.NewPersister(stateStore)
|
pr := persist.NewPersister(stateStore)
|
||||||
logg.TraceCtxf(ctx, "menu storage service", "persist", pr, "store", stateStore)
|
logg.TraceCtxf(ctx, "menu storage service", "persist", pr, "store", stateStore)
|
||||||
return pr, nil
|
return pr, nil
|
||||||
@ -195,7 +196,6 @@ func (ms *MenuStorageService) GetUserdataDb(ctx context.Context) (db.Db, error)
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = applySession(ctx, userStore)
|
err = applySession(ctx, userStore)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
Loading…
Reference in New Issue
Block a user