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:
steve-chavez
2024-04-12 14:29:39 -05:00
committed by Steve Chavez
parent 460259548d
commit 2de32fc108
10 changed files with 97 additions and 93 deletions
+4 -5
View File
@@ -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
+1
View File
@@ -141,6 +141,7 @@ baseCfg = let secret = Just $ encodeUtf8 "reallyreallyreallyreallyverysafe" in
, configRoleIsoLvl = mempty
, configInternalSCSleep = Nothing
, configServerTimingEnabled = True
, configObserver = const $ pure ()
}
testCfg :: AppConfig