Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Legacy version of Freckle.App.Database that still uses XRay
Synopsis
- class (MonadSqlBackend db, MonadUnliftIO m) => MonadSqlTx db m | m -> db where
- runSqlTx :: HasCallStack => db a -> m a
- runDB :: (MonadUnliftIO m, MonadTracer m, MonadReader app m, HasSqlPool app, HasStatsClient app) => SqlPersistT m a -> m a
- runDBSimple :: (HasSqlPool app, MonadUnliftIO m, MonadReader app m) => SqlPersistT m a -> m a
- data SqlBackend
- class HasSqlBackend a where
- getSqlBackend :: a -> SqlBackend
- class MonadUnliftIO m => MonadSqlBackend m where
- getSqlBackendM :: m SqlBackend
- liftSql :: (MonadSqlBackend m, HasCallStack) => ReaderT SqlBackend m a -> m a
- class MonadTracer m where
- getVaultData :: m (Maybe XRayVaultData)
- class HasStatsClient env
- class HasSqlPool app where
- getSqlPool :: app -> SqlPool
- type SqlPool = Pool SqlBackend
- makePostgresPool :: (MonadUnliftIO m, MonadLoggerIO m) => m SqlPool
- makePostgresPoolWith :: (MonadUnliftIO m, MonadLoggerIO m) => PostgresConnectionConf -> m SqlPool
- data PostgresConnectionConf = PostgresConnectionConf {}
- data PostgresPasswordSource
- data PostgresPassword
- type PostgresStatementTimeout = Timeout
- postgresStatementTimeoutMilliseconds :: PostgresStatementTimeout -> Int
- envParseDatabaseConf :: PostgresPasswordSource -> Parser Error PostgresConnectionConf
- envPostgresPasswordSource :: Parser Error PostgresPasswordSource
Running transactions
class (MonadSqlBackend db, MonadUnliftIO m) => MonadSqlTx db m | m -> db where Source #
The constraint
indicates that MonadSqlTx
db mm
is a monadic
context that can run db
actions, usually as a SQL transaction.
Typically, this means that db
needs a connection and m
can
provide one, e.g. from a connection pool.
runSqlTx :: HasCallStack => db a -> m a Source #
Runs the action in a SQL transaction
Instances
(HasSqlPool app, HasStatsClient app, HasTracer app) => MonadSqlTx (SqlPersistT (AppExample app)) (AppExample app) Source # | |
Defined in Freckle.App.Test runSqlTx :: HasCallStack => SqlPersistT (AppExample app) a -> AppExample app a Source # | |
(MonadUnliftIO m, HasSqlPool app, HasStatsClient app, HasTracer app) => MonadSqlTx (ReaderT SqlBackend (AppT app m)) (AppT app m) Source # | |
Defined in Freckle.App runSqlTx :: HasCallStack => ReaderT SqlBackend (AppT app m) a -> AppT app m a Source # |
runDB :: (MonadUnliftIO m, MonadTracer m, MonadReader app m, HasSqlPool app, HasStatsClient app) => SqlPersistT m a -> m a Source #
Run a Database action with connection stats and tracing
runDBSimple :: (HasSqlPool app, MonadUnliftIO m, MonadReader app m) => SqlPersistT m a -> m a Source #
Running queries
data SqlBackend #
A SqlBackend
represents a handle or connection to a database. It
contains functions and values that allow databases to have more
optimized implementations, as well as references that benefit
performance and sharing.
Instead of using the SqlBackend
constructor directly, use the
mkSqlBackend
function.
A SqlBackend
is *not* thread-safe. You should not assume that
a SqlBackend
can be shared among threads and run concurrent queries.
This *will* result in problems. Instead, you should create a
, known as a Pool
SqlBackend
ConnectionPool
, and pass that around in
multi-threaded applications.
To run actions in the persistent
library, you should use the
runSqlConn
function. If you're using a multithreaded application, use
the runSqlPool
function.
Instances
class HasSqlBackend a where Source #
getSqlBackend :: a -> SqlBackend Source #
Instances
HasSqlBackend SqlBackend Source # | |
Defined in Freckle.App.Database getSqlBackend :: SqlBackend -> SqlBackend Source # |
class MonadUnliftIO m => MonadSqlBackend m where Source #
A monadic context in which a SQL backend is available for running database queries
getSqlBackendM :: m SqlBackend Source #
Instances
(HasSqlBackend r, MonadUnliftIO m) => MonadSqlBackend (ReaderT r m) Source # | |
Defined in Freckle.App.Database getSqlBackendM :: ReaderT r m SqlBackend Source # |
liftSql :: (MonadSqlBackend m, HasCallStack) => ReaderT SqlBackend m a -> m a Source #
Generalize from SqlPersistT
to MonadSqlBackend
Telemetry
class MonadTracer m where Source #
Class for reading XRayVaultData
This is named the same as the OpenTelemetry class we'll use once we move to that tracing system
getVaultData :: m (Maybe XRayVaultData) Source #
Instances
MonadTracer (AppExample app) Source # | |
Defined in Freckle.App.Test getVaultData :: AppExample app (Maybe XRayVaultData) Source # | |
MonadTracer (HandlerFor app) Source # | |
Defined in Freckle.App.Database.XRay getVaultData :: HandlerFor app (Maybe XRayVaultData) Source # | |
Applicative m => MonadTracer (AppT app m) Source # | |
Defined in Freckle.App getVaultData :: AppT app m (Maybe XRayVaultData) Source # |
class HasStatsClient env Source #
Instances
HasStatsClient StatsClient Source # | |
Defined in Freckle.App.Stats | |
HasStatsClient site => HasStatsClient (HandlerData child site) Source # | |
Defined in Freckle.App.Stats statsClientL :: Lens' (HandlerData child site) StatsClient Source # |
Connection pools
class HasSqlPool app where Source #
getSqlPool :: app -> SqlPool Source #
Instances
HasSqlPool SqlPool Source # | |
Defined in Freckle.App.Database getSqlPool :: SqlPool -> SqlPool Source # | |
HasSqlPool site => HasSqlPool (HandlerData child site) Source # | |
Defined in Freckle.App.Database getSqlPool :: HandlerData child site -> SqlPool Source # |
type SqlPool = Pool SqlBackend Source #
makePostgresPool :: (MonadUnliftIO m, MonadLoggerIO m) => m SqlPool Source #
makePostgresPoolWith :: (MonadUnliftIO m, MonadLoggerIO m) => PostgresConnectionConf -> m SqlPool Source #
Setup
data PostgresConnectionConf Source #
Instances
Show PostgresConnectionConf Source # | |
Defined in Freckle.App.Database showsPrec :: Int -> PostgresConnectionConf -> ShowS # show :: PostgresConnectionConf -> String # showList :: [PostgresConnectionConf] -> ShowS # | |
Eq PostgresConnectionConf Source # | |
Defined in Freckle.App.Database |
data PostgresPasswordSource Source #
Instances
Show PostgresPasswordSource Source # | |
Defined in Freckle.App.Database showsPrec :: Int -> PostgresPasswordSource -> ShowS # show :: PostgresPasswordSource -> String # showList :: [PostgresPasswordSource] -> ShowS # | |
Eq PostgresPasswordSource Source # | |
Defined in Freckle.App.Database |
data PostgresPassword Source #
Instances
Show PostgresPassword Source # | |
Defined in Freckle.App.Database showsPrec :: Int -> PostgresPassword -> ShowS # show :: PostgresPassword -> String # showList :: [PostgresPassword] -> ShowS # | |
Eq PostgresPassword Source # | |
Defined in Freckle.App.Database (==) :: PostgresPassword -> PostgresPassword -> Bool # (/=) :: PostgresPassword -> PostgresPassword -> Bool # |
type PostgresStatementTimeout = Timeout Source #