| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Network.Wait.PostgreSQL
Description
This module exports variants of the functions from Network.Wait specialised for PostgreSQL servers. In addition to checking whether a connection can be established, the functions in this module also check whether the PostgreSQL server is ready to accept commands.
Synopsis
- class PostgreSqlConnectInfo a where
- connectDb :: a -> IO Connection
- waitPostgreSql :: (MonadIO m, MonadMask m, PostgreSqlConnectInfo info) => RetryPolicyM m -> info -> m Connection
- waitPostgreSqlVerbose :: (MonadIO m, MonadMask m, PostgreSqlConnectInfo info) => (String -> m ()) -> RetryPolicyM m -> info -> m Connection
- waitPostgreSqlVerboseFormat :: forall e m info. (MonadIO m, MonadMask m, PostgreSqlConnectInfo info, Exception e) => (Bool -> e -> RetryStatus -> m ()) -> RetryPolicyM m -> info -> m Connection
- waitPostgreSqlWith :: (MonadIO m, MonadMask m, PostgreSqlConnectInfo info) => [RetryStatus -> Handler m Bool] -> RetryPolicyM m -> info -> m Connection
Documentation
class PostgreSqlConnectInfo a where Source #
Used to abstract over different ways to describe a database connection.
Methods
connectDb :: a -> IO Connection Source #
connectDb info attempts to establish a database connection using
a configuration given by info.
Instances
| PostgreSqlConnectInfo ByteString Source # | |
Defined in Network.Wait.PostgreSQL Methods connectDb :: ByteString -> IO Connection Source # | |
| PostgreSqlConnectInfo ConnectInfo Source # | |
Defined in Network.Wait.PostgreSQL Methods connectDb :: ConnectInfo -> IO Connection Source # | |
waitPostgreSql :: (MonadIO m, MonadMask m, PostgreSqlConnectInfo info) => RetryPolicyM m -> info -> m Connection Source #
waitPostgreSql retryPolicy connectInfo is a variant of
waitPostgresWith which does not install any additional handlers.
waitPostgreSqlVerbose :: (MonadIO m, MonadMask m, PostgreSqlConnectInfo info) => (String -> m ()) -> RetryPolicyM m -> info -> m Connection Source #
waitPostgreSqlVerbose outputHandler retryPolicy connectInfo is a variant
of waitPostgreSqlVerboseFormat which catches all exceptions derived from
SomeException and formats retry attempt information using defaultLogMsg
before passing the resulting String to out.
waitPostgreSqlVerboseFormat :: forall e m info. (MonadIO m, MonadMask m, PostgreSqlConnectInfo info, Exception e) => (Bool -> e -> RetryStatus -> m ()) -> RetryPolicyM m -> info -> m Connection Source #
waitPostgreSqlVerboseFormat outputHandler retryPolicy connectInfo is a
variant of waitPostgreSqlWith which installs an extra handler based on
logRetries which passes status information for each retry attempt
to outputHandler.
waitPostgreSqlWith :: (MonadIO m, MonadMask m, PostgreSqlConnectInfo info) => [RetryStatus -> Handler m Bool] -> RetryPolicyM m -> info -> m Connection Source #
waitPostgreSqlWith extraHandlers retryPolicy connectInfo will attempt
to connect to the PostgreSQL server using connectInfo and check that the
server is ready to accept commands. If this check fails, retryPolicy is
used to determine whether (and how often) this function should attempt to
retry establishing the connection. By default, this function will retry
after all exceptions (except for those given by skipAsyncExceptions).
This behaviour may be customised with extraHandlers which are installed
after skipAsyncExceptions, but before the default exception handler. The
extraHandlers may also be used to report retry attempts to e.g. the
standard output or a logger.