diff --git a/consumers/CHANGELOG.md b/consumers/CHANGELOG.md index 487016b..0de28c3 100644 --- a/consumers/CHANGELOG.md +++ b/consumers/CHANGELOG.md @@ -1,3 +1,6 @@ +# consumers-2.3.5.0 (2026-??-??) +* Add `hoistConsumer` to `Database.PostgreSQL.Consumers.Config`. + # consumers-2.3.4.0 (2025-11-27) * Compatibility with `hpqtypes` >= 1.13.0.0. diff --git a/consumers/consumers.cabal b/consumers/consumers.cabal index 5754092..b9a3e96 100644 --- a/consumers/consumers.cabal +++ b/consumers/consumers.cabal @@ -1,6 +1,6 @@ cabal-version: 3.0 name: consumers -version: 2.3.4.0 +version: 2.3.5.0 synopsis: Concurrent PostgreSQL data consumers description: Library for setting up concurrent consumers of data diff --git a/consumers/src/Database/PostgreSQL/Consumers/Config.hs b/consumers/src/Database/PostgreSQL/Consumers/Config.hs index fde9636..b759594 100644 --- a/consumers/src/Database/PostgreSQL/Consumers/Config.hs +++ b/consumers/src/Database/PostgreSQL/Consumers/Config.hs @@ -2,6 +2,7 @@ module Database.PostgreSQL.Consumers.Config ( Action (..) , Result (..) , ConsumerConfig (..) + , hoistConsumer ) where import Control.Exception (SomeException) @@ -117,3 +118,15 @@ data ConsumerConfig m idx job = forall row. FromRow row => ConsumerConfig , ccJobLogData :: !(job -> [A.Pair]) -- ^ Data to attach to each log message while processing a job. } + +-- | Change the monad the consumer lives in. +hoistConsumer + :: (forall r. m r -> n r) + -> ConsumerConfig m idx job + -> ConsumerConfig n idx job +hoistConsumer f ConsumerConfig {..} = + ConsumerConfig + { ccProcessJob = f . ccProcessJob + , ccOnException = \ex -> f . ccOnException ex + , .. + }