arbiter-core-0.1.0.0: Core types and logic for PostgreSQL-backed job queue
Safe HaskellNone
LanguageGHC2024

Arbiter.Core.MonadArbiter

Synopsis

Documentation

class (Monad m, MonadIO m) => MonadArbiter (m :: Type -> Type) where Source #

Database abstraction for job queue operations. Each backend (postgresql-simple, hasql, orville) provides an instance that maps queries to its native driver.

Associated Types

type Handler (m :: Type -> Type) jobs result Source #

Backend-specific handler type (e.g., Connection -> jobs -> IO result).

Methods

executeQuery :: Text -> Params -> RowCodec a -> m [a] Source #

Run a parameterized query and decode the result rows.

executeStatement :: Text -> Params -> m Int64 Source #

Run a parameterized statement, returning the number of affected rows.

withDbTransaction :: m a -> m a Source #

Run an action in a transaction. Nesting creates savepoints.

runHandlerWithConnection :: Handler m jobs result -> jobs -> m result Source #

Run a handler with a database connection from the pool.

type Params = [SomeParam] Source #

Positional query parameters.

data SomeParam where Source #

An existentially-typed parameter: a ParamType paired with its value.

Constructors

SomeParam :: forall a. ParamType a -> a -> SomeParam 

data ParamType a where Source #

How a parameter is shaped: scalar, nullable, or array.

Constructors

PScalar :: forall a. Col a -> ParamType a 
PNullable :: forall a1. Col a1 -> ParamType (Maybe a1) 
PArray :: forall a1. Col a1 -> ParamType [a1] 
PNullArray :: forall a1. Col a1 -> ParamType [Maybe a1] 

type JobHandler (m :: Type -> Type) payload result = Handler m (JobRead payload) result Source #

type BatchedJobHandler (m :: Type -> Type) payload result = Handler m (NonEmpty (JobRead payload)) result Source #