Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Postgres Execute Types
Execution context and source configuration for Postgres databases. Provides support for things such as read-only transactions and read replicas.
Synopsis
- data PGExecCtx = PGExecCtx {
- _pecRunTx :: PGExecCtxInfo -> RunTx
- _pecDestroyConnections :: IO ()
- _pecResizePools :: ServerReplicas -> IO SourceResizePoolSummary
- data PGExecCtxInfo = PGExecCtxInfo {}
- data PGExecTxType
- = NoTxRead
- | Tx TxAccess (Maybe TxIsolation)
- data PGExecFrom
- mkPGExecCtx :: TxIsolation -> PGPool -> ResizePoolStrategy -> PGExecCtx
- resizePostgresPool :: PGPool -> Int -> ServerReplicas -> IO ()
- defaultTxErrorHandler :: PGTxErr -> QErr
- dmlTxErrorHandler :: PGTxErr -> QErr
- mkTxErrorHandler :: (PGErrorType -> Bool) -> PGTxErr -> QErr
- data ConnectionTemplateConfig
- connectionTemplateConfigResolver :: ConnectionTemplateConfig -> Maybe ConnectionTemplateResolver
- newtype ConnectionTemplateResolver = ConnectionTemplateResolver {
- _runResolver :: forall m. MonadError QErr m => SessionVariables -> [Header] -> Maybe QueryContext -> m PostgresResolvedConnectionTemplate
- data PGSourceConfig = PGSourceConfig {}
- runPgSourceReadTx :: (MonadIO m, MonadBaseControl IO m) => PGSourceConfig -> TxET QErr m a -> m (Either QErr a)
- runPgSourceWriteTx :: (MonadIO m, MonadBaseControl IO m) => PGSourceConfig -> PGExecFrom -> TxET QErr m a -> m (Either QErr a)
- applyConnectionTemplateResolverNonAdmin :: MonadError QErr m => Maybe ConnectionTemplateResolver -> UserInfo -> [Header] -> Maybe QueryContext -> m (Maybe PostgresResolvedConnectionTemplate)
- pgResolveConnectionTemplate :: MonadError QErr m => PGSourceConfig -> RequestContext -> Maybe ConnectionTemplate -> m EncJSON
- resolvePostgresConnectionTemplate :: MonadError QErr m => ConnectionTemplate -> [PostgresConnectionSetMemberName] -> SessionVariables -> [Header] -> Maybe QueryContext -> m PostgresResolvedConnectionTemplate
- sourceConfigNumReadReplicas :: PGSourceConfig -> Int
- sourceConfigConnectonTemplateEnabled :: PGSourceConfig -> Bool
Documentation
PGExecCtx | |
|
data PGExecCtxInfo Source #
Holds the information required to exceute a PG transaction
PGExecCtxInfo | |
|
data PGExecTxType Source #
The tranasction mode (isolation level, transaction access) for executing the transaction
data PGExecFrom Source #
The level from where the transaction is being run
GraphQLQuery (Maybe PostgresResolvedConnectionTemplate) | transaction initated via a GraphQLRequest |
RunSQLQuery | transaction initiated during run_sql |
InternalRawQuery | custom transaction Hasura runs on the database. This is usually used in event_trigger and actions |
LegacyRQLQuery | transactions initiated via other API's other than |
mkPGExecCtx :: TxIsolation -> PGPool -> ResizePoolStrategy -> PGExecCtx Source #
Creates a Postgres execution context for a single Postgres master pool
resizePostgresPool :: PGPool -> Int -> ServerReplicas -> IO () Source #
Resize Postgres pool by setting the number of connections equal to allowed maximum connections across all server instances divided by number of instances
defaultTxErrorHandler :: PGTxErr -> QErr Source #
dmlTxErrorHandler :: PGTxErr -> QErr Source #
Constructs a transaction error handler tailored for the needs of RQL's DML.
mkTxErrorHandler :: (PGErrorType -> Bool) -> PGTxErr -> QErr Source #
Constructs a transaction error handler given a predicate that determines which errors are expected and should be reported to the user. All other errors are considered internal errors.
data ConnectionTemplateConfig Source #
ConnTemplate_NotApplicable | Connection templates are disabled for Hasura CE |
ConnTemplate_NotConfigured | |
ConnTemplate_Resolver ConnectionTemplateResolver |
connectionTemplateConfigResolver :: ConnectionTemplateConfig -> Maybe ConnectionTemplateResolver Source #
newtype ConnectionTemplateResolver Source #
A hook to resolve connection template
ConnectionTemplateResolver | |
|
data PGSourceConfig Source #
Instances
runPgSourceReadTx :: (MonadIO m, MonadBaseControl IO m) => PGSourceConfig -> TxET QErr m a -> m (Either QErr a) Source #
runPgSourceWriteTx :: (MonadIO m, MonadBaseControl IO m) => PGSourceConfig -> PGExecFrom -> TxET QErr m a -> m (Either QErr a) Source #
applyConnectionTemplateResolverNonAdmin :: MonadError QErr m => Maybe ConnectionTemplateResolver -> UserInfo -> [Header] -> Maybe QueryContext -> m (Maybe PostgresResolvedConnectionTemplate) Source #
Resolve connection templates only for non-admin roles
pgResolveConnectionTemplate :: MonadError QErr m => PGSourceConfig -> RequestContext -> Maybe ConnectionTemplate -> m EncJSON Source #