| Safe Haskell | None |
|---|---|
| Language | GHC2024 |
Arbiter.Core.MonadArbiter
Description
The database primitives every backend implements.
Synopsis
- class MonadUnliftIO m => MonadArbiter (m :: Type -> Type) where
- type RegistryOf (m :: Type -> Type) :: JobPayloadRegistry
- type Handler (m :: Type -> Type) job result
- getSchema :: m SchemaName
- executeQuery :: Query a -> m [a]
- executeQueryPrepared :: Query a -> m [a]
- executeStatement :: Query a -> m Int64
- withDbTransaction :: m a -> m a
- runHandlerWithConnection :: JobHandler m payload (ResultOf m payload) -> JobRead payload -> m (ResultOf m payload)
- getListener :: m (Maybe Listener)
- type JobHandler (m :: Type -> Type) payload result = Handler m (JobRead payload) result
- type HasRegistry (m :: Type -> Type) (registry :: JobPayloadRegistry) = (MonadArbiter m, RegistryOf m ~ registry)
- type ResultOf (m :: Type -> Type) payload = ResultFor payload (RegistryOf m)
- type Params = [SomeParam]
- data SomeParam where
- data ParamType a where
- data Query a = Query {}
Documentation
Source #class MonadUnliftIO m => MonadArbiter (m :: Type -> Type) where
Database abstraction for job queue operations. Each backend (postgresql-simple, hasql, orville) provides an instance that maps queries to its native driver.
The instance also names the monad's schema and queue registry. The high-level API resolves table names and result types from them at compile time.
Minimal complete definition
getSchema, executeQuery, executeStatement, withDbTransaction, runHandlerWithConnection, getListener
Associated Types
Source #type RegistryOf (m :: Type -> Type) :: JobPayloadRegistry
This monad's registry. The default reports an instance that omits it.
type RegistryOf (m :: Type -> Type) = TypeError ((('Text "No registry declared for " ':<>: 'ShowType m) ':$$: 'Text "Its MonadArbiter instance is missing the RegistryOf definition.") ':$$: (('Text "Add to the instance: type RegistryOf " ':<>: 'ShowType m) ':<>: 'Text " = YourRegistry")) :: JobPayloadRegistry
Source #type Handler (m :: Type -> Type) job result
Backend-specific handler shape (e.g. Connection -> job -> m result).
JobHandler instantiates it at one queue's job and result types.
Methods
Source #getSchema :: m SchemaName
The schema name for this monad's Arbiter tables.
Source #executeQuery :: Query a -> m [a]
Run a query and decode the result rows. The text, its parameters, and the
decoder travel together in the Query.
Source #executeQueryPrepared :: Query a -> m [a]
executeQuery for a hot statement whose text is stable across calls. A
backend may prepare it once per connection.
Source #executeStatement :: Query a -> m Int64
Run a statement, returning the number of affected rows. The Query
decoder is ignored.
Source #withDbTransaction :: m a -> m a
Run an action in a transaction. Nesting creates savepoints.
Source #runHandlerWithConnection :: JobHandler m payload (ResultOf m payload) -> JobRead payload -> m (ResultOf m payload)
Run a job handler with a database connection from the pool.
Source #getListener :: m (Maybe Listener)
The env's shared LISTEN/NOTIFY listener, or Nothing for poll-only.
Source #type JobHandler (m :: Type -> Type) payload result = Handler m (JobRead payload) result
A handler for payload's queue. result is what its registry entry declares.
Source #type HasRegistry (m :: Type -> Type) (registry :: JobPayloadRegistry) = (MonadArbiter m, RegistryOf m ~ registry)
MonadArbiter with the registry named, for signatures that mention it.
Source #type ResultOf (m :: Type -> Type) payload = ResultFor payload (RegistryOf m)
The result type declared by payload's registry entry. It is not injective.
A signature naming it needs another argument to determine payload.
An existentially-typed parameter. A ParamType paired with its value.
A parameterized query paired with the decoder for its result rows.
Constructors
| Query | |