Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- genTag :: Member (AtomicState ConnectionsState) r => Sem r ConnectionTag
- tagForSource :: Member (AtomicState ConnectionsState) r => ConnectionSource -> Sem r (Either Connection ConnectionTag)
- needsInit :: Member (AtomicState ConnectionsState) r => InitDb m -> Int -> Sem r Bool
- runInit :: Members [AtomicState ConnectionsState, Log, Embed IO] r => InitDb (Sem r) -> Int -> Connection -> Sem r ()
- acquireConnection :: Members [DbConnectionPool !! DbConnectionError, AtomicState ConnectionState, Stop DbError, Lock] r => ConnectionTag -> Sem r (Int, Connection)
- releaseConnection :: Members [DbConnectionPool !! DbConnectionError, AtomicState ConnectionState, Log] r => ConnectionTag -> Sem r ()
- releaseBadConnection :: Members [DbConnectionPool !! DbConnectionError, AtomicState ConnectionState, Stop DbError, Log, Lock, Embed IO] r => ConnectionTag -> Connection -> Sem r ()
- bracketConnection :: Member Resource r => Members [DbConnectionPool !! DbConnectionError, AtomicState ConnectionState, Stop DbError, Log, Lock, Embed IO] r => ConnectionTag -> (Int -> Connection -> Sem r a) -> Sem r a
- withInit :: Members [AtomicState ConnectionsState, Stop DbError, Log, Embed IO] r => Int -> Connection -> InitDb (Sem r) -> Sem r a -> Sem r a
- withInitManaged :: Members [AtomicState ConnectionState, AtomicState ConnectionsState, DbConnectionPool !! DbConnectionError] r => Members [Stop DbError, Lock, Resource, Log, Embed IO] r => ConnectionTag -> InitDb (Sem r) -> (Connection -> Sem r a) -> Sem r a
- retrying :: Members [DbConnectionPool !! DbConnectionError, Time t d, Stop DbError, Resource, Embed IO] r => (Int, NanoSeconds) -> Sem (Stop DbError ': r) a -> Sem r a
- managedConnection :: forall r m t d a. Members [AtomicState ConnectionsState, AtomicState ConnectionState, DbConnectionPool !! DbConnectionError] r => Members [Time t d, Resource, Lock, Log, Embed IO] r => ConnectionTag -> InitDb (Sem r) -> Maybe (Int, NanoSeconds) -> Database m a -> Tactical (Database !! DbError) m (Stop DbError ': r) a
- unmanagedConnection :: forall r m a. Members [AtomicState ConnectionsState, AtomicState ConnectionState, DbConnectionPool !! DbConnectionError] r => Members [Resource, Lock, Log, Embed IO, Final IO] r => Connection -> InitDb (Sem r) -> Database m a -> Tactical (Database !! DbError) m (Stop DbError ': r) a
- handleDatabase :: forall r m a t d. Members [AtomicState ConnectionsState, AtomicState ConnectionState, DbConnectionPool !! DbConnectionError] r => Members [Time t d, Resource, Lock, Log, Embed IO, Final IO] r => Either Connection ConnectionTag -> Database m a -> Tactical (Database !! DbError) m (Stop DbError ': r) a
- type DatabaseScope = [AtomicState ConnectionState, Lock]
- databaseScope :: Members [DbConnectionPool !! DbConnectionError, AtomicState ConnectionsState, Resource, Mask, Race, Embed IO] r => (Either Connection ConnectionTag -> Sem (DatabaseScope ++ r) a) -> ConnectionSource -> Sem r a
- interpretDatabases :: forall t d r. Members [DbConnectionPool !! DbConnectionError, AtomicState ConnectionsState] r => Members [Time t d, Log, Resource, Mask, Race, Embed IO, Final IO] r => InterpreterFor (Scoped ConnectionSource (Database !! DbError)) r
- interpretDatabase :: forall t d r. Members [DbConnectionPool !! DbConnectionError, Time t d, Resource, Log, Mask, Race, Embed IO, Final IO] r => InterpretersFor [Database !! DbError, Scoped ConnectionSource (Database !! DbError)] r
- type HasqlStack = [Database !! DbError, Scoped ConnectionSource (Database !! DbError), DbConnectionPool !! DbConnectionError]
- interpretHasql :: Members [Time t d, Log, Mask, Resource, Race, Embed IO, Final IO] r => DbConfig -> Maybe Int -> Maybe Int -> InterpretersFor HasqlStack r
Documentation
genTag :: Member (AtomicState ConnectionsState) r => Sem r ConnectionTag Source #
tagForSource :: Member (AtomicState ConnectionsState) r => ConnectionSource -> Sem r (Either Connection ConnectionTag) Source #
needsInit :: Member (AtomicState ConnectionsState) r => InitDb m -> Int -> Sem r Bool Source #
runInit :: Members [AtomicState ConnectionsState, Log, Embed IO] r => InitDb (Sem r) -> Int -> Connection -> Sem r () Source #
acquireConnection :: Members [DbConnectionPool !! DbConnectionError, AtomicState ConnectionState, Stop DbError, Lock] r => ConnectionTag -> Sem r (Int, Connection) Source #
releaseConnection :: Members [DbConnectionPool !! DbConnectionError, AtomicState ConnectionState, Log] r => ConnectionTag -> Sem r () Source #
releaseBadConnection :: Members [DbConnectionPool !! DbConnectionError, AtomicState ConnectionState, Stop DbError, Log, Lock, Embed IO] r => ConnectionTag -> Connection -> Sem r () Source #
After a computation failed, the Postgres connection needs to be health-checked.
If the status is ConnectionBad
, remove the connection from the state and release it, causing the next call to
acquireConnection
to request a new one.
It is conceivable for the connection to be stuck in a startup phase like ConnectionSSLStartup
, but since
hasql only uses a connection that is fully established, it shouldn't happen.
TODO Can't hurt to investigate this anyway.
bracketConnection :: Member Resource r => Members [DbConnectionPool !! DbConnectionError, AtomicState ConnectionState, Stop DbError, Log, Lock, Embed IO] r => ConnectionTag -> (Int -> Connection -> Sem r a) -> Sem r a Source #
withInit :: Members [AtomicState ConnectionsState, Stop DbError, Log, Embed IO] r => Int -> Connection -> InitDb (Sem r) -> Sem r a -> Sem r a Source #
withInitManaged :: Members [AtomicState ConnectionState, AtomicState ConnectionsState, DbConnectionPool !! DbConnectionError] r => Members [Stop DbError, Lock, Resource, Log, Embed IO] r => ConnectionTag -> InitDb (Sem r) -> (Connection -> Sem r a) -> Sem r a Source #
retrying :: Members [DbConnectionPool !! DbConnectionError, Time t d, Stop DbError, Resource, Embed IO] r => (Int, NanoSeconds) -> Sem (Stop DbError ': r) a -> Sem r a Source #
managedConnection :: forall r m t d a. Members [AtomicState ConnectionsState, AtomicState ConnectionState, DbConnectionPool !! DbConnectionError] r => Members [Time t d, Resource, Lock, Log, Embed IO] r => ConnectionTag -> InitDb (Sem r) -> Maybe (Int, NanoSeconds) -> Database m a -> Tactical (Database !! DbError) m (Stop DbError ': r) a Source #
unmanagedConnection :: forall r m a. Members [AtomicState ConnectionsState, AtomicState ConnectionState, DbConnectionPool !! DbConnectionError] r => Members [Resource, Lock, Log, Embed IO, Final IO] r => Connection -> InitDb (Sem r) -> Database m a -> Tactical (Database !! DbError) m (Stop DbError ': r) a Source #
handleDatabase :: forall r m a t d. Members [AtomicState ConnectionsState, AtomicState ConnectionState, DbConnectionPool !! DbConnectionError] r => Members [Time t d, Resource, Lock, Log, Embed IO, Final IO] r => Either Connection ConnectionTag -> Database m a -> Tactical (Database !! DbError) m (Stop DbError ': r) a Source #
type DatabaseScope = [AtomicState ConnectionState, Lock] Source #
databaseScope :: Members [DbConnectionPool !! DbConnectionError, AtomicState ConnectionsState, Resource, Mask, Race, Embed IO] r => (Either Connection ConnectionTag -> Sem (DatabaseScope ++ r) a) -> ConnectionSource -> Sem r a Source #
interpretDatabases :: forall t d r. Members [DbConnectionPool !! DbConnectionError, AtomicState ConnectionsState] r => Members [Time t d, Log, Resource, Mask, Race, Embed IO, Final IO] r => InterpreterFor (Scoped ConnectionSource (Database !! DbError)) r Source #
interpretDatabase :: forall t d r. Members [DbConnectionPool !! DbConnectionError, Time t d, Resource, Log, Mask, Race, Embed IO, Final IO] r => InterpretersFor [Database !! DbError, Scoped ConnectionSource (Database !! DbError)] r Source #