refactor: observation handler to AppConfig
With this: - Is no longer necessary to pass observer as an argument to every function that needs observations. - We can invoke the observer on every function that uses AppConfig. However it'd be better to just call the observer in the upper modules (like on App.hs).
This commit is contained in:
committed by
Steve Chavez
parent
460259548d
commit
2de32fc108
+4
-5
@@ -77,21 +77,20 @@ main = do
|
||||
sockets <- AppState.initSockets testCfg
|
||||
|
||||
let
|
||||
noObs = const $ pure ()
|
||||
-- For tests that run with the same refSchemaCache
|
||||
app config = do
|
||||
appState <- AppState.initWithPool sockets pool config noObs
|
||||
appState <- AppState.initWithPool sockets pool config
|
||||
AppState.putPgVersion appState actualPgVersion
|
||||
AppState.putSchemaCache appState (Just baseSchemaCache)
|
||||
return ((), postgrest (configLogLevel config) appState (pure ()) noObs)
|
||||
return ((), postgrest (configLogLevel config) appState (pure ()))
|
||||
|
||||
-- For tests that run with a different SchemaCache(depends on configSchemas)
|
||||
appDbs config = do
|
||||
customSchemaCache <- loadSCache pool config
|
||||
appState <- AppState.initWithPool sockets pool config noObs
|
||||
appState <- AppState.initWithPool sockets pool config
|
||||
AppState.putPgVersion appState actualPgVersion
|
||||
AppState.putSchemaCache appState (Just customSchemaCache)
|
||||
return ((), postgrest (configLogLevel config) appState (pure ()) noObs)
|
||||
return ((), postgrest (configLogLevel config) appState (pure ()))
|
||||
|
||||
let withApp = app testCfg
|
||||
maxRowsApp = app testMaxRowsCfg
|
||||
|
||||
@@ -141,6 +141,7 @@ baseCfg = let secret = Just $ encodeUtf8 "reallyreallyreallyreallyverysafe" in
|
||||
, configRoleIsoLvl = mempty
|
||||
, configInternalSCSleep = Nothing
|
||||
, configServerTimingEnabled = True
|
||||
, configObserver = const $ pure ()
|
||||
}
|
||||
|
||||
testCfg :: AppConfig
|
||||
|
||||
Reference in New Issue
Block a user