Copyright | Flipstone Technology Partners 2023 |
---|---|
License | MIT |
Stability | Stable |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Since: 1.0.0.0
Synopsis
- data OrvilleState
- newOrvilleState :: ErrorDetailLevel -> ConnectionPool -> OrvilleState
- resetOrvilleState :: OrvilleState -> OrvilleState
- orvilleConnectionPool :: OrvilleState -> ConnectionPool
- orvilleErrorDetailLevel :: OrvilleState -> ErrorDetailLevel
- orvilleTransactionCallback :: OrvilleState -> TransactionEvent -> IO ()
- orvilleSqlCommenterAttributes :: OrvilleState -> Maybe SqlCommenterAttributes
- addTransactionCallback :: (TransactionEvent -> IO ()) -> OrvilleState -> OrvilleState
- data TransactionEvent
- data Savepoint
- savepointNestingLevel :: Savepoint -> Int
- initialSavepoint :: Savepoint
- nextSavepoint :: Savepoint -> Savepoint
- orvilleSqlExecutionCallback :: OrvilleState -> forall a. QueryType -> RawSql -> IO a -> IO a
- addSqlExecutionCallback :: (forall a. QueryType -> RawSql -> IO a -> IO a) -> OrvilleState -> OrvilleState
- orvilleBeginTransactionExpr :: OrvilleState -> BeginTransactionExpr
- setBeginTransactionExpr :: BeginTransactionExpr -> OrvilleState -> OrvilleState
- setSqlCommenterAttributes :: SqlCommenterAttributes -> OrvilleState -> OrvilleState
- addSqlCommenterAttributes :: SqlCommenterAttributes -> OrvilleState -> OrvilleState
Documentation
data OrvilleState Source #
OrvilleState
is used to manage opening connections to the database,
transactions, etc. newOrvilleState
should be used to create an appopriate
initial state for your monad's context.
Since: 1.0.0.0
Instances
(MonadOrvilleControl m, MonadIO m) => MonadOrville (ReaderT OrvilleState m) Source # | |
Defined in Orville.PostgreSQL.Internal.MonadOrville | |
Monad m => HasOrvilleState (ReaderT OrvilleState m) Source # | |
Defined in Orville.PostgreSQL.Monad.HasOrvilleState askOrvilleState :: ReaderT OrvilleState m OrvilleState Source # localOrvilleState :: (OrvilleState -> OrvilleState) -> ReaderT OrvilleState m a -> ReaderT OrvilleState m a Source # |
newOrvilleState :: ErrorDetailLevel -> ConnectionPool -> OrvilleState Source #
Creates an appropriate initial OrvilleState
that will use the connection
pool given to initiate connections to the database.
Since: 1.0.0.0
resetOrvilleState :: OrvilleState -> OrvilleState Source #
Creates a new initial OrvilleState
using the connection pool from the
provided state. You might need to use this if you are spawning one Orville
monad from another and they should not share the same connection and
transaction state.
Since: 1.0.0.0
orvilleConnectionPool :: OrvilleState -> ConnectionPool Source #
Get the connection pool being used for the OrvilleState
.
Since: 1.0.0.0
orvilleErrorDetailLevel :: OrvilleState -> ErrorDetailLevel Source #
The ErrorDetailLevel
controls how much information Orville includes in
error messages it generates when data cannot be decoded from rows in the
database.
Since: 1.0.0.0
orvilleTransactionCallback :: OrvilleState -> TransactionEvent -> IO () Source #
Orville will call the transaction callback any time a transaction event
occurs. You can register a callback with addTransactionCallback
.
Since: 1.0.0.0
orvilleSqlCommenterAttributes :: OrvilleState -> Maybe SqlCommenterAttributes Source #
The SqlCommenter attributes that Orville will include with queries. These can
be modified with addSqlCommenterAttributes
. See
https://google.github.io/sqlcommenter/.
Since: 1.0.0.0
addTransactionCallback :: (TransactionEvent -> IO ()) -> OrvilleState -> OrvilleState Source #
Registers a callback to be invoked during transactions.
The callback given will be called after the SQL statement corresponding to the given event has finished executing. Callbacks will be called in the order they are added.
Note: There is no specialized error handling for these callbacks. This means that if a callback raises an exception, no further callbacks will be called and the exception will propagate up until it is caught elsewhere. In particular, if an exception is raised by a callback upon opening the transaction, it will cause the transaction to be rolled-back the same as any other exception that might happen during the transaction. In general, we recommend only using callbacks that either raise no exceptions or can handle their own exceptions cleanly.
Since: 1.0.0.0
data TransactionEvent Source #
Describes an event in the lifecycle of a database transaction. You can use
addTransactionCallback
to register a callback to respond to these events.
The callback will be called after the event in question has been successfully
executed.
Since: 1.0.0.0
BeginTransaction | Indicates a new transaction has been started. |
NewSavepoint Savepoint | Indicates that a new savepoint has been saved within a transaction. |
ReleaseSavepoint Savepoint | Indicates that a previous savepoint has been released. It can no longer be rolled back to. |
RollbackToSavepoint Savepoint | Indicates that rollback was performed to a prior savepoint. Note: It is possible to rollback to a savepoint prior to the most recent
one without releasing or rolling back to intermediate savepoints. Doing
so destroys any savepoints created after the given savepoint. Although
Orville currently always matches |
CommitTransaction | Indicates that the transaction has been committed. |
RollbackTransaction | Indicates that the transaction has been rolled back. |
Instances
Show TransactionEvent Source # | |
Defined in Orville.PostgreSQL.Internal.OrvilleState showsPrec :: Int -> TransactionEvent -> ShowS # show :: TransactionEvent -> String # showList :: [TransactionEvent] -> ShowS # | |
Eq TransactionEvent Source # | |
Defined in Orville.PostgreSQL.Internal.OrvilleState (==) :: TransactionEvent -> TransactionEvent -> Bool # (/=) :: TransactionEvent -> TransactionEvent -> Bool # |
An internal Orville identifier for a savepoint in a PostgreSQL transaction.
Since: 1.0.0.0
savepointNestingLevel :: Savepoint -> Int Source #
Indicates how many levels of nested savepoints the given Savepoint
identifier represents.
Since: 1.0.0.0
initialSavepoint :: Savepoint Source #
The initial identifier Orville uses to track the first savepoint within a transaction.
Since: 1.0.0.0
nextSavepoint :: Savepoint -> Savepoint Source #
Determines the identifier for the next savepoint in a transaction after the given savepoint.
Since: 1.0.0.0
orvilleSqlExecutionCallback :: OrvilleState -> forall a. QueryType -> RawSql -> IO a -> IO a Source #
The callback Orville will call whenever it wants to run SQL. You can
register a callback using addSqlExecutionCallback
.
Since: 1.0.0.0
addSqlExecutionCallback :: (forall a. QueryType -> RawSql -> IO a -> IO a) -> OrvilleState -> OrvilleState Source #
Adds a callback to be called when an Orville operation executes a SQL statement. The callback is given the IO action that will perform the query execution and must call that action for the query to be run. In particular, you can use this to time queries and log any that are slow.
Calls to any previously added callbacks will also be executed as part of the IO action passed to the new callback. Thus the newly added callback happens "around" the previously added callback.
There is no special exception handling done for these callbacks beyond what they implement themselves. Any callbacks should allow for the possibility that the IO action they are given may raise an exception.
Since: 1.0.0.0
orvilleBeginTransactionExpr :: OrvilleState -> BeginTransactionExpr Source #
The SQL expression that Orville will use to begin a transaction. You can set
this via setBeginTransactionExpr
to have fine-grained control over the
transaction parameters, such as isolation level.
Since: 1.0.0.0
setBeginTransactionExpr :: BeginTransactionExpr -> OrvilleState -> OrvilleState Source #
Sets the SQL expression that Orville will use to begin transactions. You can
control the transaction isolation level by building your own
BeginTransactionExpr
with the desired isolation level.
Since: 1.0.0.0
setSqlCommenterAttributes :: SqlCommenterAttributes -> OrvilleState -> OrvilleState Source #
Sets the SqlCommenterAttributes that Orville will then add to any following statement executions.
Since: 1.0.0.0
addSqlCommenterAttributes :: SqlCommenterAttributes -> OrvilleState -> OrvilleState Source #
Adds the SqlCommenterAttributes to the already existing attributes that Orville will then add to any following statement executions.
Since: 1.0.0.0