{-# LANGUAGE OverloadedStrings #-}
module Arbiter.Core.Codec
(
Col (..)
, NullCol (..)
, RowCodec
, col
, ncol
, pureVal
, runCodec
, codecColumns
, ParamType (..)
, SomeParam (..)
, Params
, pval
, pnul
, parr
, pnarr
, jobRowCodec
, dlqRowCodec
, countCodec
, statsRowCodec
) where
import Control.Applicative.Free.Final (Ap, liftAp, runAp, runAp_)
import Data.Aeson (Value)
import Data.Int (Int32, Int64)
import Data.Maybe (isJust)
import Data.Text (Text)
import Data.Time (UTCTime)
import Arbiter.Core.Job.Types (DedupKey (..), Job (..))
data Col a where
CInt4 :: Col Int32
CInt8 :: Col Int64
CText :: Col Text
CBool :: Col Bool
CTimestamptz :: Col UTCTime
CJsonb :: Col Value
CFloat8 :: Col Double
data NullCol a where
NotNull :: Text -> Col a -> NullCol a
Nullable :: Text -> Col a -> NullCol (Maybe a)
type RowCodec = Ap NullCol
col :: Text -> Col a -> RowCodec a
col :: forall a. Text -> Col a -> RowCodec a
col Text
name Col a
c = NullCol a -> Ap NullCol a
forall (f :: * -> *) a. f a -> Ap f a
liftAp (Text -> Col a -> NullCol a
forall a. Text -> Col a -> NullCol a
NotNull Text
name Col a
c)
ncol :: Text -> Col a -> RowCodec (Maybe a)
ncol :: forall a. Text -> Col a -> RowCodec (Maybe a)
ncol Text
name Col a
c = NullCol (Maybe a) -> Ap NullCol (Maybe a)
forall (f :: * -> *) a. f a -> Ap f a
liftAp (Text -> Col a -> NullCol (Maybe a)
forall a. Text -> Col a -> NullCol (Maybe a)
Nullable Text
name Col a
c)
pureVal :: a -> RowCodec a
pureVal :: forall a. a -> RowCodec a
pureVal = a -> Ap NullCol a
forall a. a -> RowCodec a
forall (f :: * -> *) a. Applicative f => a -> f a
pure
runCodec :: (Applicative f) => (forall x. NullCol x -> f x) -> RowCodec a -> f a
runCodec :: forall (f :: * -> *) a.
Applicative f =>
(forall x. NullCol x -> f x) -> RowCodec a -> f a
runCodec = (forall x. NullCol x -> f x) -> Ap NullCol a -> f a
forall (g :: * -> *) (f :: * -> *) a.
Applicative g =>
(forall x. f x -> g x) -> Ap f a -> g a
runAp
codecColumns :: RowCodec a -> [Text]
codecColumns :: forall a. RowCodec a -> [Text]
codecColumns = (forall a. NullCol a -> [Text]) -> Ap NullCol a -> [Text]
forall m (f :: * -> *) b.
Monoid m =>
(forall a. f a -> m) -> Ap f b -> m
runAp_ NullCol a -> [Text]
forall a. NullCol a -> [Text]
colName
where
colName :: NullCol a -> [Text]
colName :: forall a. NullCol a -> [Text]
colName (NotNull Text
name Col a
_) = [Text
name]
colName (Nullable Text
name Col a
_) = [Text
name]
data ParamType a where
PScalar :: Col a -> ParamType a
PNullable :: Col a -> ParamType (Maybe a)
PArray :: Col a -> ParamType [a]
PNullArray :: Col a -> ParamType [Maybe a]
data SomeParam where
SomeParam :: ParamType a -> a -> SomeParam
type Params = [SomeParam]
pval :: Col a -> a -> SomeParam
pval :: forall a. Col a -> a -> SomeParam
pval Col a
c a
v = ParamType a -> a -> SomeParam
forall a. ParamType a -> a -> SomeParam
SomeParam (Col a -> ParamType a
forall a. Col a -> ParamType a
PScalar Col a
c) a
v
pnul :: Col a -> Maybe a -> SomeParam
pnul :: forall a. Col a -> Maybe a -> SomeParam
pnul Col a
c Maybe a
v = ParamType (Maybe a) -> Maybe a -> SomeParam
forall a. ParamType a -> a -> SomeParam
SomeParam (Col a -> ParamType (Maybe a)
forall a. Col a -> ParamType (Maybe a)
PNullable Col a
c) Maybe a
v
parr :: Col a -> [a] -> SomeParam
parr :: forall a. Col a -> [a] -> SomeParam
parr Col a
c [a]
v = ParamType [a] -> [a] -> SomeParam
forall a. ParamType a -> a -> SomeParam
SomeParam (Col a -> ParamType [a]
forall a. Col a -> ParamType [a]
PArray Col a
c) [a]
v
pnarr :: Col a -> [Maybe a] -> SomeParam
pnarr :: forall a. Col a -> [Maybe a] -> SomeParam
pnarr Col a
c [Maybe a]
v = ParamType [Maybe a] -> [Maybe a] -> SomeParam
forall a. ParamType a -> a -> SomeParam
SomeParam (Col a -> ParamType [Maybe a]
forall a. Col a -> ParamType [Maybe a]
PNullArray Col a
c) [Maybe a]
v
jobRowCodec :: Text -> RowCodec (Job Value Int64 Text UTCTime)
jobRowCodec :: Text -> RowCodec (Job Value Int64 Text UTCTime)
jobRowCodec Text
queueName =
Int64
-> Value
-> Text
-> Maybe Text
-> UTCTime
-> Maybe UTCTime
-> Int32
-> Maybe Text
-> Int32
-> Maybe UTCTime
-> Maybe UTCTime
-> Maybe DedupKey
-> Maybe Int32
-> Maybe Int64
-> Bool
-> Bool
-> Job Value Int64 Text UTCTime
forall payload key q insertedAt.
key
-> payload
-> q
-> Maybe Text
-> insertedAt
-> Maybe UTCTime
-> Int32
-> Maybe Text
-> Int32
-> Maybe UTCTime
-> Maybe UTCTime
-> Maybe DedupKey
-> Maybe Int32
-> Maybe Int64
-> Bool
-> Bool
-> Job payload key q insertedAt
Job
(Int64
-> Value
-> Text
-> Maybe Text
-> UTCTime
-> Maybe UTCTime
-> Int32
-> Maybe Text
-> Int32
-> Maybe UTCTime
-> Maybe UTCTime
-> Maybe DedupKey
-> Maybe Int32
-> Maybe Int64
-> Bool
-> Bool
-> Job Value Int64 Text UTCTime)
-> Ap NullCol Int64
-> Ap
NullCol
(Value
-> Text
-> Maybe Text
-> UTCTime
-> Maybe UTCTime
-> Int32
-> Maybe Text
-> Int32
-> Maybe UTCTime
-> Maybe UTCTime
-> Maybe DedupKey
-> Maybe Int32
-> Maybe Int64
-> Bool
-> Bool
-> Job Value Int64 Text UTCTime)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Text -> Col Int64 -> Ap NullCol Int64
forall a. Text -> Col a -> RowCodec a
col Text
"id" Col Int64
CInt8
Ap
NullCol
(Value
-> Text
-> Maybe Text
-> UTCTime
-> Maybe UTCTime
-> Int32
-> Maybe Text
-> Int32
-> Maybe UTCTime
-> Maybe UTCTime
-> Maybe DedupKey
-> Maybe Int32
-> Maybe Int64
-> Bool
-> Bool
-> Job Value Int64 Text UTCTime)
-> Ap NullCol Value
-> Ap
NullCol
(Text
-> Maybe Text
-> UTCTime
-> Maybe UTCTime
-> Int32
-> Maybe Text
-> Int32
-> Maybe UTCTime
-> Maybe UTCTime
-> Maybe DedupKey
-> Maybe Int32
-> Maybe Int64
-> Bool
-> Bool
-> Job Value Int64 Text UTCTime)
forall a b. Ap NullCol (a -> b) -> Ap NullCol a -> Ap NullCol b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Col Value -> Ap NullCol Value
forall a. Text -> Col a -> RowCodec a
col Text
"payload" Col Value
CJsonb
Ap
NullCol
(Text
-> Maybe Text
-> UTCTime
-> Maybe UTCTime
-> Int32
-> Maybe Text
-> Int32
-> Maybe UTCTime
-> Maybe UTCTime
-> Maybe DedupKey
-> Maybe Int32
-> Maybe Int64
-> Bool
-> Bool
-> Job Value Int64 Text UTCTime)
-> Ap NullCol Text
-> Ap
NullCol
(Maybe Text
-> UTCTime
-> Maybe UTCTime
-> Int32
-> Maybe Text
-> Int32
-> Maybe UTCTime
-> Maybe UTCTime
-> Maybe DedupKey
-> Maybe Int32
-> Maybe Int64
-> Bool
-> Bool
-> Job Value Int64 Text UTCTime)
forall a b. Ap NullCol (a -> b) -> Ap NullCol a -> Ap NullCol b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Ap NullCol Text
forall a. a -> RowCodec a
pureVal Text
queueName
Ap
NullCol
(Maybe Text
-> UTCTime
-> Maybe UTCTime
-> Int32
-> Maybe Text
-> Int32
-> Maybe UTCTime
-> Maybe UTCTime
-> Maybe DedupKey
-> Maybe Int32
-> Maybe Int64
-> Bool
-> Bool
-> Job Value Int64 Text UTCTime)
-> Ap NullCol (Maybe Text)
-> Ap
NullCol
(UTCTime
-> Maybe UTCTime
-> Int32
-> Maybe Text
-> Int32
-> Maybe UTCTime
-> Maybe UTCTime
-> Maybe DedupKey
-> Maybe Int32
-> Maybe Int64
-> Bool
-> Bool
-> Job Value Int64 Text UTCTime)
forall a b. Ap NullCol (a -> b) -> Ap NullCol a -> Ap NullCol b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Col Text -> Ap NullCol (Maybe Text)
forall a. Text -> Col a -> RowCodec (Maybe a)
ncol Text
"group_key" Col Text
CText
Ap
NullCol
(UTCTime
-> Maybe UTCTime
-> Int32
-> Maybe Text
-> Int32
-> Maybe UTCTime
-> Maybe UTCTime
-> Maybe DedupKey
-> Maybe Int32
-> Maybe Int64
-> Bool
-> Bool
-> Job Value Int64 Text UTCTime)
-> Ap NullCol UTCTime
-> Ap
NullCol
(Maybe UTCTime
-> Int32
-> Maybe Text
-> Int32
-> Maybe UTCTime
-> Maybe UTCTime
-> Maybe DedupKey
-> Maybe Int32
-> Maybe Int64
-> Bool
-> Bool
-> Job Value Int64 Text UTCTime)
forall a b. Ap NullCol (a -> b) -> Ap NullCol a -> Ap NullCol b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Col UTCTime -> Ap NullCol UTCTime
forall a. Text -> Col a -> RowCodec a
col Text
"inserted_at" Col UTCTime
CTimestamptz
Ap
NullCol
(Maybe UTCTime
-> Int32
-> Maybe Text
-> Int32
-> Maybe UTCTime
-> Maybe UTCTime
-> Maybe DedupKey
-> Maybe Int32
-> Maybe Int64
-> Bool
-> Bool
-> Job Value Int64 Text UTCTime)
-> Ap NullCol (Maybe UTCTime)
-> Ap
NullCol
(Int32
-> Maybe Text
-> Int32
-> Maybe UTCTime
-> Maybe UTCTime
-> Maybe DedupKey
-> Maybe Int32
-> Maybe Int64
-> Bool
-> Bool
-> Job Value Int64 Text UTCTime)
forall a b. Ap NullCol (a -> b) -> Ap NullCol a -> Ap NullCol b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Col UTCTime -> Ap NullCol (Maybe UTCTime)
forall a. Text -> Col a -> RowCodec (Maybe a)
ncol Text
"updated_at" Col UTCTime
CTimestamptz
Ap
NullCol
(Int32
-> Maybe Text
-> Int32
-> Maybe UTCTime
-> Maybe UTCTime
-> Maybe DedupKey
-> Maybe Int32
-> Maybe Int64
-> Bool
-> Bool
-> Job Value Int64 Text UTCTime)
-> Ap NullCol Int32
-> Ap
NullCol
(Maybe Text
-> Int32
-> Maybe UTCTime
-> Maybe UTCTime
-> Maybe DedupKey
-> Maybe Int32
-> Maybe Int64
-> Bool
-> Bool
-> Job Value Int64 Text UTCTime)
forall a b. Ap NullCol (a -> b) -> Ap NullCol a -> Ap NullCol b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Col Int32 -> Ap NullCol Int32
forall a. Text -> Col a -> RowCodec a
col Text
"attempts" Col Int32
CInt4
Ap
NullCol
(Maybe Text
-> Int32
-> Maybe UTCTime
-> Maybe UTCTime
-> Maybe DedupKey
-> Maybe Int32
-> Maybe Int64
-> Bool
-> Bool
-> Job Value Int64 Text UTCTime)
-> Ap NullCol (Maybe Text)
-> Ap
NullCol
(Int32
-> Maybe UTCTime
-> Maybe UTCTime
-> Maybe DedupKey
-> Maybe Int32
-> Maybe Int64
-> Bool
-> Bool
-> Job Value Int64 Text UTCTime)
forall a b. Ap NullCol (a -> b) -> Ap NullCol a -> Ap NullCol b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Col Text -> Ap NullCol (Maybe Text)
forall a. Text -> Col a -> RowCodec (Maybe a)
ncol Text
"last_error" Col Text
CText
Ap
NullCol
(Int32
-> Maybe UTCTime
-> Maybe UTCTime
-> Maybe DedupKey
-> Maybe Int32
-> Maybe Int64
-> Bool
-> Bool
-> Job Value Int64 Text UTCTime)
-> Ap NullCol Int32
-> Ap
NullCol
(Maybe UTCTime
-> Maybe UTCTime
-> Maybe DedupKey
-> Maybe Int32
-> Maybe Int64
-> Bool
-> Bool
-> Job Value Int64 Text UTCTime)
forall a b. Ap NullCol (a -> b) -> Ap NullCol a -> Ap NullCol b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Col Int32 -> Ap NullCol Int32
forall a. Text -> Col a -> RowCodec a
col Text
"priority" Col Int32
CInt4
Ap
NullCol
(Maybe UTCTime
-> Maybe UTCTime
-> Maybe DedupKey
-> Maybe Int32
-> Maybe Int64
-> Bool
-> Bool
-> Job Value Int64 Text UTCTime)
-> Ap NullCol (Maybe UTCTime)
-> Ap
NullCol
(Maybe UTCTime
-> Maybe DedupKey
-> Maybe Int32
-> Maybe Int64
-> Bool
-> Bool
-> Job Value Int64 Text UTCTime)
forall a b. Ap NullCol (a -> b) -> Ap NullCol a -> Ap NullCol b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Col UTCTime -> Ap NullCol (Maybe UTCTime)
forall a. Text -> Col a -> RowCodec (Maybe a)
ncol Text
"last_attempted_at" Col UTCTime
CTimestamptz
Ap
NullCol
(Maybe UTCTime
-> Maybe DedupKey
-> Maybe Int32
-> Maybe Int64
-> Bool
-> Bool
-> Job Value Int64 Text UTCTime)
-> Ap NullCol (Maybe UTCTime)
-> Ap
NullCol
(Maybe DedupKey
-> Maybe Int32
-> Maybe Int64
-> Bool
-> Bool
-> Job Value Int64 Text UTCTime)
forall a b. Ap NullCol (a -> b) -> Ap NullCol a -> Ap NullCol b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Col UTCTime -> Ap NullCol (Maybe UTCTime)
forall a. Text -> Col a -> RowCodec (Maybe a)
ncol Text
"not_visible_until" Col UTCTime
CTimestamptz
Ap
NullCol
(Maybe DedupKey
-> Maybe Int32
-> Maybe Int64
-> Bool
-> Bool
-> Job Value Int64 Text UTCTime)
-> Ap NullCol (Maybe DedupKey)
-> Ap
NullCol
(Maybe Int32
-> Maybe Int64 -> Bool -> Bool -> Job Value Int64 Text UTCTime)
forall a b. Ap NullCol (a -> b) -> Ap NullCol a -> Ap NullCol b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Ap NullCol (Maybe DedupKey)
dedupKeyCodec
Ap
NullCol
(Maybe Int32
-> Maybe Int64 -> Bool -> Bool -> Job Value Int64 Text UTCTime)
-> Ap NullCol (Maybe Int32)
-> Ap
NullCol
(Maybe Int64 -> Bool -> Bool -> Job Value Int64 Text UTCTime)
forall a b. Ap NullCol (a -> b) -> Ap NullCol a -> Ap NullCol b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Col Int32 -> Ap NullCol (Maybe Int32)
forall a. Text -> Col a -> RowCodec (Maybe a)
ncol Text
"max_attempts" Col Int32
CInt4
Ap
NullCol
(Maybe Int64 -> Bool -> Bool -> Job Value Int64 Text UTCTime)
-> Ap NullCol (Maybe Int64)
-> Ap NullCol (Bool -> Bool -> Job Value Int64 Text UTCTime)
forall a b. Ap NullCol (a -> b) -> Ap NullCol a -> Ap NullCol b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Col Int64 -> Ap NullCol (Maybe Int64)
forall a. Text -> Col a -> RowCodec (Maybe a)
ncol Text
"parent_id" Col Int64
CInt8
Ap NullCol (Bool -> Bool -> Job Value Int64 Text UTCTime)
-> Ap NullCol Bool
-> Ap NullCol (Bool -> Job Value Int64 Text UTCTime)
forall a b. Ap NullCol (a -> b) -> Ap NullCol a -> Ap NullCol b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (Maybe Value -> Bool
forall a. Maybe a -> Bool
isJust (Maybe Value -> Bool)
-> Ap NullCol (Maybe Value) -> Ap NullCol Bool
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Text -> Col Value -> Ap NullCol (Maybe Value)
forall a. Text -> Col a -> RowCodec (Maybe a)
ncol Text
"parent_state" Col Value
CJsonb)
Ap NullCol (Bool -> Job Value Int64 Text UTCTime)
-> Ap NullCol Bool -> RowCodec (Job Value Int64 Text UTCTime)
forall a b. Ap NullCol (a -> b) -> Ap NullCol a -> Ap NullCol b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Col Bool -> Ap NullCol Bool
forall a. Text -> Col a -> RowCodec a
col Text
"suspended" Col Bool
CBool
dedupKeyCodec :: RowCodec (Maybe DedupKey)
dedupKeyCodec :: Ap NullCol (Maybe DedupKey)
dedupKeyCodec = Maybe Text -> Maybe Text -> Maybe DedupKey
forall {a}.
(Eq a, IsString a) =>
Maybe Text -> Maybe a -> Maybe DedupKey
toDedupKey (Maybe Text -> Maybe Text -> Maybe DedupKey)
-> Ap NullCol (Maybe Text)
-> Ap NullCol (Maybe Text -> Maybe DedupKey)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Text -> Col Text -> Ap NullCol (Maybe Text)
forall a. Text -> Col a -> RowCodec (Maybe a)
ncol Text
"dedup_key" Col Text
CText Ap NullCol (Maybe Text -> Maybe DedupKey)
-> Ap NullCol (Maybe Text) -> Ap NullCol (Maybe DedupKey)
forall a b. Ap NullCol (a -> b) -> Ap NullCol a -> Ap NullCol b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Col Text -> Ap NullCol (Maybe Text)
forall a. Text -> Col a -> RowCodec (Maybe a)
ncol Text
"dedup_strategy" Col Text
CText
where
toDedupKey :: Maybe Text -> Maybe a -> Maybe DedupKey
toDedupKey Maybe Text
Nothing Maybe a
_ = Maybe DedupKey
forall a. Maybe a
Nothing
toDedupKey (Just Text
k) (Just a
"replace") = DedupKey -> Maybe DedupKey
forall a. a -> Maybe a
Just (Text -> DedupKey
ReplaceDuplicate Text
k)
toDedupKey (Just Text
k) Maybe a
_ = DedupKey -> Maybe DedupKey
forall a. a -> Maybe a
Just (Text -> DedupKey
IgnoreDuplicate Text
k)
dlqRowCodec :: Text -> RowCodec (Int64, UTCTime, Job Value Int64 Text UTCTime)
dlqRowCodec :: Text -> RowCodec (Int64, UTCTime, Job Value Int64 Text UTCTime)
dlqRowCodec Text
queueName =
(,,)
(Int64
-> UTCTime
-> Job Value Int64 Text UTCTime
-> (Int64, UTCTime, Job Value Int64 Text UTCTime))
-> Ap NullCol Int64
-> Ap
NullCol
(UTCTime
-> Job Value Int64 Text UTCTime
-> (Int64, UTCTime, Job Value Int64 Text UTCTime))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Text -> Col Int64 -> Ap NullCol Int64
forall a. Text -> Col a -> RowCodec a
col Text
"id" Col Int64
CInt8
Ap
NullCol
(UTCTime
-> Job Value Int64 Text UTCTime
-> (Int64, UTCTime, Job Value Int64 Text UTCTime))
-> Ap NullCol UTCTime
-> Ap
NullCol
(Job Value Int64 Text UTCTime
-> (Int64, UTCTime, Job Value Int64 Text UTCTime))
forall a b. Ap NullCol (a -> b) -> Ap NullCol a -> Ap NullCol b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Col UTCTime -> Ap NullCol UTCTime
forall a. Text -> Col a -> RowCodec a
col Text
"failed_at" Col UTCTime
CTimestamptz
Ap
NullCol
(Job Value Int64 Text UTCTime
-> (Int64, UTCTime, Job Value Int64 Text UTCTime))
-> RowCodec (Job Value Int64 Text UTCTime)
-> RowCodec (Int64, UTCTime, Job Value Int64 Text UTCTime)
forall a b. Ap NullCol (a -> b) -> Ap NullCol a -> Ap NullCol b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> RowCodec (Job Value Int64 Text UTCTime)
jobRowCodecWithJobId Text
queueName
jobRowCodecWithJobId :: Text -> RowCodec (Job Value Int64 Text UTCTime)
jobRowCodecWithJobId :: Text -> RowCodec (Job Value Int64 Text UTCTime)
jobRowCodecWithJobId Text
queueName =
Int64
-> Value
-> Text
-> Maybe Text
-> UTCTime
-> Maybe UTCTime
-> Int32
-> Maybe Text
-> Int32
-> Maybe UTCTime
-> Maybe UTCTime
-> Maybe DedupKey
-> Maybe Int32
-> Maybe Int64
-> Bool
-> Bool
-> Job Value Int64 Text UTCTime
forall payload key q insertedAt.
key
-> payload
-> q
-> Maybe Text
-> insertedAt
-> Maybe UTCTime
-> Int32
-> Maybe Text
-> Int32
-> Maybe UTCTime
-> Maybe UTCTime
-> Maybe DedupKey
-> Maybe Int32
-> Maybe Int64
-> Bool
-> Bool
-> Job payload key q insertedAt
Job
(Int64
-> Value
-> Text
-> Maybe Text
-> UTCTime
-> Maybe UTCTime
-> Int32
-> Maybe Text
-> Int32
-> Maybe UTCTime
-> Maybe UTCTime
-> Maybe DedupKey
-> Maybe Int32
-> Maybe Int64
-> Bool
-> Bool
-> Job Value Int64 Text UTCTime)
-> Ap NullCol Int64
-> Ap
NullCol
(Value
-> Text
-> Maybe Text
-> UTCTime
-> Maybe UTCTime
-> Int32
-> Maybe Text
-> Int32
-> Maybe UTCTime
-> Maybe UTCTime
-> Maybe DedupKey
-> Maybe Int32
-> Maybe Int64
-> Bool
-> Bool
-> Job Value Int64 Text UTCTime)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Text -> Col Int64 -> Ap NullCol Int64
forall a. Text -> Col a -> RowCodec a
col Text
"job_id" Col Int64
CInt8
Ap
NullCol
(Value
-> Text
-> Maybe Text
-> UTCTime
-> Maybe UTCTime
-> Int32
-> Maybe Text
-> Int32
-> Maybe UTCTime
-> Maybe UTCTime
-> Maybe DedupKey
-> Maybe Int32
-> Maybe Int64
-> Bool
-> Bool
-> Job Value Int64 Text UTCTime)
-> Ap NullCol Value
-> Ap
NullCol
(Text
-> Maybe Text
-> UTCTime
-> Maybe UTCTime
-> Int32
-> Maybe Text
-> Int32
-> Maybe UTCTime
-> Maybe UTCTime
-> Maybe DedupKey
-> Maybe Int32
-> Maybe Int64
-> Bool
-> Bool
-> Job Value Int64 Text UTCTime)
forall a b. Ap NullCol (a -> b) -> Ap NullCol a -> Ap NullCol b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Col Value -> Ap NullCol Value
forall a. Text -> Col a -> RowCodec a
col Text
"payload" Col Value
CJsonb
Ap
NullCol
(Text
-> Maybe Text
-> UTCTime
-> Maybe UTCTime
-> Int32
-> Maybe Text
-> Int32
-> Maybe UTCTime
-> Maybe UTCTime
-> Maybe DedupKey
-> Maybe Int32
-> Maybe Int64
-> Bool
-> Bool
-> Job Value Int64 Text UTCTime)
-> Ap NullCol Text
-> Ap
NullCol
(Maybe Text
-> UTCTime
-> Maybe UTCTime
-> Int32
-> Maybe Text
-> Int32
-> Maybe UTCTime
-> Maybe UTCTime
-> Maybe DedupKey
-> Maybe Int32
-> Maybe Int64
-> Bool
-> Bool
-> Job Value Int64 Text UTCTime)
forall a b. Ap NullCol (a -> b) -> Ap NullCol a -> Ap NullCol b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Ap NullCol Text
forall a. a -> RowCodec a
pureVal Text
queueName
Ap
NullCol
(Maybe Text
-> UTCTime
-> Maybe UTCTime
-> Int32
-> Maybe Text
-> Int32
-> Maybe UTCTime
-> Maybe UTCTime
-> Maybe DedupKey
-> Maybe Int32
-> Maybe Int64
-> Bool
-> Bool
-> Job Value Int64 Text UTCTime)
-> Ap NullCol (Maybe Text)
-> Ap
NullCol
(UTCTime
-> Maybe UTCTime
-> Int32
-> Maybe Text
-> Int32
-> Maybe UTCTime
-> Maybe UTCTime
-> Maybe DedupKey
-> Maybe Int32
-> Maybe Int64
-> Bool
-> Bool
-> Job Value Int64 Text UTCTime)
forall a b. Ap NullCol (a -> b) -> Ap NullCol a -> Ap NullCol b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Col Text -> Ap NullCol (Maybe Text)
forall a. Text -> Col a -> RowCodec (Maybe a)
ncol Text
"group_key" Col Text
CText
Ap
NullCol
(UTCTime
-> Maybe UTCTime
-> Int32
-> Maybe Text
-> Int32
-> Maybe UTCTime
-> Maybe UTCTime
-> Maybe DedupKey
-> Maybe Int32
-> Maybe Int64
-> Bool
-> Bool
-> Job Value Int64 Text UTCTime)
-> Ap NullCol UTCTime
-> Ap
NullCol
(Maybe UTCTime
-> Int32
-> Maybe Text
-> Int32
-> Maybe UTCTime
-> Maybe UTCTime
-> Maybe DedupKey
-> Maybe Int32
-> Maybe Int64
-> Bool
-> Bool
-> Job Value Int64 Text UTCTime)
forall a b. Ap NullCol (a -> b) -> Ap NullCol a -> Ap NullCol b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Col UTCTime -> Ap NullCol UTCTime
forall a. Text -> Col a -> RowCodec a
col Text
"inserted_at" Col UTCTime
CTimestamptz
Ap
NullCol
(Maybe UTCTime
-> Int32
-> Maybe Text
-> Int32
-> Maybe UTCTime
-> Maybe UTCTime
-> Maybe DedupKey
-> Maybe Int32
-> Maybe Int64
-> Bool
-> Bool
-> Job Value Int64 Text UTCTime)
-> Ap NullCol (Maybe UTCTime)
-> Ap
NullCol
(Int32
-> Maybe Text
-> Int32
-> Maybe UTCTime
-> Maybe UTCTime
-> Maybe DedupKey
-> Maybe Int32
-> Maybe Int64
-> Bool
-> Bool
-> Job Value Int64 Text UTCTime)
forall a b. Ap NullCol (a -> b) -> Ap NullCol a -> Ap NullCol b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Col UTCTime -> Ap NullCol (Maybe UTCTime)
forall a. Text -> Col a -> RowCodec (Maybe a)
ncol Text
"updated_at" Col UTCTime
CTimestamptz
Ap
NullCol
(Int32
-> Maybe Text
-> Int32
-> Maybe UTCTime
-> Maybe UTCTime
-> Maybe DedupKey
-> Maybe Int32
-> Maybe Int64
-> Bool
-> Bool
-> Job Value Int64 Text UTCTime)
-> Ap NullCol Int32
-> Ap
NullCol
(Maybe Text
-> Int32
-> Maybe UTCTime
-> Maybe UTCTime
-> Maybe DedupKey
-> Maybe Int32
-> Maybe Int64
-> Bool
-> Bool
-> Job Value Int64 Text UTCTime)
forall a b. Ap NullCol (a -> b) -> Ap NullCol a -> Ap NullCol b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Col Int32 -> Ap NullCol Int32
forall a. Text -> Col a -> RowCodec a
col Text
"attempts" Col Int32
CInt4
Ap
NullCol
(Maybe Text
-> Int32
-> Maybe UTCTime
-> Maybe UTCTime
-> Maybe DedupKey
-> Maybe Int32
-> Maybe Int64
-> Bool
-> Bool
-> Job Value Int64 Text UTCTime)
-> Ap NullCol (Maybe Text)
-> Ap
NullCol
(Int32
-> Maybe UTCTime
-> Maybe UTCTime
-> Maybe DedupKey
-> Maybe Int32
-> Maybe Int64
-> Bool
-> Bool
-> Job Value Int64 Text UTCTime)
forall a b. Ap NullCol (a -> b) -> Ap NullCol a -> Ap NullCol b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Col Text -> Ap NullCol (Maybe Text)
forall a. Text -> Col a -> RowCodec (Maybe a)
ncol Text
"last_error" Col Text
CText
Ap
NullCol
(Int32
-> Maybe UTCTime
-> Maybe UTCTime
-> Maybe DedupKey
-> Maybe Int32
-> Maybe Int64
-> Bool
-> Bool
-> Job Value Int64 Text UTCTime)
-> Ap NullCol Int32
-> Ap
NullCol
(Maybe UTCTime
-> Maybe UTCTime
-> Maybe DedupKey
-> Maybe Int32
-> Maybe Int64
-> Bool
-> Bool
-> Job Value Int64 Text UTCTime)
forall a b. Ap NullCol (a -> b) -> Ap NullCol a -> Ap NullCol b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Col Int32 -> Ap NullCol Int32
forall a. Text -> Col a -> RowCodec a
col Text
"priority" Col Int32
CInt4
Ap
NullCol
(Maybe UTCTime
-> Maybe UTCTime
-> Maybe DedupKey
-> Maybe Int32
-> Maybe Int64
-> Bool
-> Bool
-> Job Value Int64 Text UTCTime)
-> Ap NullCol (Maybe UTCTime)
-> Ap
NullCol
(Maybe UTCTime
-> Maybe DedupKey
-> Maybe Int32
-> Maybe Int64
-> Bool
-> Bool
-> Job Value Int64 Text UTCTime)
forall a b. Ap NullCol (a -> b) -> Ap NullCol a -> Ap NullCol b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Col UTCTime -> Ap NullCol (Maybe UTCTime)
forall a. Text -> Col a -> RowCodec (Maybe a)
ncol Text
"last_attempted_at" Col UTCTime
CTimestamptz
Ap
NullCol
(Maybe UTCTime
-> Maybe DedupKey
-> Maybe Int32
-> Maybe Int64
-> Bool
-> Bool
-> Job Value Int64 Text UTCTime)
-> Ap NullCol (Maybe UTCTime)
-> Ap
NullCol
(Maybe DedupKey
-> Maybe Int32
-> Maybe Int64
-> Bool
-> Bool
-> Job Value Int64 Text UTCTime)
forall a b. Ap NullCol (a -> b) -> Ap NullCol a -> Ap NullCol b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Col UTCTime -> Ap NullCol (Maybe UTCTime)
forall a. Text -> Col a -> RowCodec (Maybe a)
ncol Text
"not_visible_until" Col UTCTime
CTimestamptz
Ap
NullCol
(Maybe DedupKey
-> Maybe Int32
-> Maybe Int64
-> Bool
-> Bool
-> Job Value Int64 Text UTCTime)
-> Ap NullCol (Maybe DedupKey)
-> Ap
NullCol
(Maybe Int32
-> Maybe Int64 -> Bool -> Bool -> Job Value Int64 Text UTCTime)
forall a b. Ap NullCol (a -> b) -> Ap NullCol a -> Ap NullCol b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Ap NullCol (Maybe DedupKey)
dedupKeyCodec
Ap
NullCol
(Maybe Int32
-> Maybe Int64 -> Bool -> Bool -> Job Value Int64 Text UTCTime)
-> Ap NullCol (Maybe Int32)
-> Ap
NullCol
(Maybe Int64 -> Bool -> Bool -> Job Value Int64 Text UTCTime)
forall a b. Ap NullCol (a -> b) -> Ap NullCol a -> Ap NullCol b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Col Int32 -> Ap NullCol (Maybe Int32)
forall a. Text -> Col a -> RowCodec (Maybe a)
ncol Text
"max_attempts" Col Int32
CInt4
Ap
NullCol
(Maybe Int64 -> Bool -> Bool -> Job Value Int64 Text UTCTime)
-> Ap NullCol (Maybe Int64)
-> Ap NullCol (Bool -> Bool -> Job Value Int64 Text UTCTime)
forall a b. Ap NullCol (a -> b) -> Ap NullCol a -> Ap NullCol b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Col Int64 -> Ap NullCol (Maybe Int64)
forall a. Text -> Col a -> RowCodec (Maybe a)
ncol Text
"parent_id" Col Int64
CInt8
Ap NullCol (Bool -> Bool -> Job Value Int64 Text UTCTime)
-> Ap NullCol Bool
-> Ap NullCol (Bool -> Job Value Int64 Text UTCTime)
forall a b. Ap NullCol (a -> b) -> Ap NullCol a -> Ap NullCol b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (Maybe Value -> Bool
forall a. Maybe a -> Bool
isJust (Maybe Value -> Bool)
-> Ap NullCol (Maybe Value) -> Ap NullCol Bool
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Text -> Col Value -> Ap NullCol (Maybe Value)
forall a. Text -> Col a -> RowCodec (Maybe a)
ncol Text
"parent_state" Col Value
CJsonb)
Ap NullCol (Bool -> Job Value Int64 Text UTCTime)
-> Ap NullCol Bool -> RowCodec (Job Value Int64 Text UTCTime)
forall a b. Ap NullCol (a -> b) -> Ap NullCol a -> Ap NullCol b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Col Bool -> Ap NullCol Bool
forall a. Text -> Col a -> RowCodec a
col Text
"suspended" Col Bool
CBool
countCodec :: RowCodec Int64
countCodec :: Ap NullCol Int64
countCodec = Text -> Col Int64 -> Ap NullCol Int64
forall a. Text -> Col a -> RowCodec a
col Text
"count" Col Int64
CInt8
statsRowCodec :: RowCodec (Int64, Int64, Maybe Double)
statsRowCodec :: RowCodec (Int64, Int64, Maybe Double)
statsRowCodec =
(,,)
(Int64 -> Int64 -> Maybe Double -> (Int64, Int64, Maybe Double))
-> Ap NullCol Int64
-> Ap
NullCol (Int64 -> Maybe Double -> (Int64, Int64, Maybe Double))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Text -> Col Int64 -> Ap NullCol Int64
forall a. Text -> Col a -> RowCodec a
col Text
"total_jobs" Col Int64
CInt8
Ap NullCol (Int64 -> Maybe Double -> (Int64, Int64, Maybe Double))
-> Ap NullCol Int64
-> Ap NullCol (Maybe Double -> (Int64, Int64, Maybe Double))
forall a b. Ap NullCol (a -> b) -> Ap NullCol a -> Ap NullCol b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Col Int64 -> Ap NullCol Int64
forall a. Text -> Col a -> RowCodec a
col Text
"visible_jobs" Col Int64
CInt8
Ap NullCol (Maybe Double -> (Int64, Int64, Maybe Double))
-> Ap NullCol (Maybe Double)
-> RowCodec (Int64, Int64, Maybe Double)
forall a b. Ap NullCol (a -> b) -> Ap NullCol a -> Ap NullCol b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Col Double -> Ap NullCol (Maybe Double)
forall a. Text -> Col a -> RowCodec (Maybe a)
ncol Text
"oldest_job_age_seconds" Col Double
CFloat8