Safe Haskell | None |
---|---|
Language | Haskell2010 |
Data.MultiPool.Persist.Postgresql
Synopsis
- initMultiPool :: (MonadLogger m, MonadUnliftIO m) => ConnectionString -> Int -> [(InstanceName SqlReadBackend, ConnectionString, Int)] -> m (MultiPool SqlBackend)
- initMultiPool' :: (MonadLogger m, MonadUnliftIO m) => (MultiPool SqlBackend -> IO (Maybe (InstanceName SqlReadBackend))) -> ConnectionString -> Int -> [(InstanceName SqlReadBackend, ConnectionString, Int)] -> m (MultiPool SqlBackend)
- runReadCurrent :: MonadUnliftIO m => MultiPool SqlBackend -> HashMap (InstanceName SqlReadBackend) LSN -> LSN -> ReaderT SqlReadBackend m a -> m a
- getLastLSN :: MonadIO m => ReaderT SqlReadBackend m LSN
- gatherLSNs :: MonadUnliftIO m => MultiPool SqlBackend -> m (HashMap (InstanceName SqlReadBackend) LSN)
Documentation
initMultiPool :: (MonadLogger m, MonadUnliftIO m) => ConnectionString -> Int -> [(InstanceName SqlReadBackend, ConnectionString, Int)] -> m (MultiPool SqlBackend) Source #
Arguments
:: (MonadLogger m, MonadUnliftIO m) | |
=> (MultiPool SqlBackend -> IO (Maybe (InstanceName SqlReadBackend))) | |
-> ConnectionString | Primary connection string |
-> Int | Max number of connections to primary instance |
-> [(InstanceName SqlReadBackend, ConnectionString, Int)] | Replica connection details |
-> m (MultiPool SqlBackend) |
runReadCurrent :: MonadUnliftIO m => MultiPool SqlBackend -> HashMap (InstanceName SqlReadBackend) LSN -> LSN -> ReaderT SqlReadBackend m a -> m a Source #
Performs a read on the first replica found that sufficiently up-to-date with the given LSN. This function can be combined with gatherLSNs
and some sort of caching mechanism to provide a simple way to scale out reads. An great article on this concept can be found here
If no replica is up-to-date with the given LSN, the primary instance will be used to run the query.
getLastLSN :: MonadIO m => ReaderT SqlReadBackend m LSN Source #
gatherLSNs :: MonadUnliftIO m => MultiPool SqlBackend -> m (HashMap (InstanceName SqlReadBackend) LSN) Source #