Haskell 应用程序的数据库与队列集成实践
在开发应用程序时,数据库和队列系统的集成是非常重要的环节。本文将详细介绍如何在 Haskell 应用程序中集成 PostgreSQL、Redis 和 RabbitMQ,以及相关的操作步骤和代码示例。
1. PostgreSQL 集成
在 someFunc 函数中,我们需要进行一些修改以集成 PostgreSQL:
someFunc :: IO ()
someFunc = withKatip $ \le -> do
mState <- newTVarIO M.initialState
PG.withState pgCfg $ \pgState -> run le (pgState, mState) action
where
pgCfg = PG.Config
{ PG.configUrl = "postgresql://localhost/hauth"
, PG.configStripeCount = 2
, PG.configMaxOpenConnPerStripe = 5
, PG.configIdleConnTimeout = 10
}
这里添加了 PG.withState 函数来获取 PG.State ,并将其用于构建传递给 run 函数的
超级会员免费看
订阅专栏 解锁全文
13

被折叠的 条评论
为什么被折叠?



