17 lines
838 B
Plaintext
17 lines
838 B
Plaintext
runConnectionPool :: MonadControlIO m => Action m a -> ConnectionPool -> m a
|
|
runConnectionPool = runMongoDBConn (ConfirmWrites [u"j" =: True])
|
|
|
|
withConnectionPool :: (MonadControlIO m, Applicative m) => AppConfig -> (ConnectionPool -> m b) -> m b
|
|
withConnectionPool conf f = do
|
|
(database,host) <- liftIO $ loadConnParams (appEnv conf)
|
|
withMongoDBPool (u database) host (connectionPoolSize conf) f
|
|
where
|
|
-- | The database connection parameters.
|
|
-- loadConnParams :: AppEnvironment -> IO (Database, HostName)
|
|
loadConnParams env = do
|
|
allSettings <- (join $ YAML.decodeFile ("config/mongoDB.yml" :: String)) >>= fromMapping
|
|
settings <- lookupMapping (show env) allSettings
|
|
database <- lookupScalar "database" settings
|
|
host <- lookupScalar "host" settings
|
|
return (database, host)
|