{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE DuplicateRecordFields #-}
module Arbiter.Core.HighLevel
(
QueueOperation
, JobOperation
, RegistryAdmissionPolicies
, insertJob
, insertJobsBatch
, insertJobsBatch_
, claimNextVisibleJobs
, claimNextVisibleJobsAs
, claimNextVisibleJobsBatched
, ackJob
, ackJobsBatch
, updateJobForRetry
, nackJob
, nackJobAfter
, nackJobsBatch
, nackJobsBatchAfter
, setVisibilityTimeout
, setVisibilityTimeoutBatch
, SetVisibilityResult (..)
, addRateLimitTokens
, pruneRateLimitBuckets
, resetRateLimitBuckets
, listRateLimitPolicies
, getRateLimitPolicy
, rateLimitPolicyExists
, listRateLimitBuckets
, updateRateLimitPolicyOverrides
, setRateLimit
, clearRateLimit
, listConcurrencyPolicies
, getConcurrencyPolicy
, concurrencyPolicyExists
, listConcurrencyKeys
, updateConcurrencyPolicyOverrides
, setConcurrencyLimit
, clearConcurrencyLimit
, pruneConcurrencyKeys
, reconcileConcurrencyCounts
, reconcileConcurrencyCountsIfStale
, reconcileAndPruneConcurrency
, Ops.JobFilter (..)
, Ops.JobSortColumn (..)
, Ops.DLQSortColumn (..)
, Ops.ArchiveSortColumn (..)
, Ops.SortDir (..)
, listJobsFiltered
, countJobsFiltered
, listDLQFiltered
, countDLQFiltered
, listArchiveFiltered
, countArchiveFiltered
, moveToDLQ
, moveToDLQBatch
, listDLQJobs
, retryFromDLQ
, retryFromDLQWithPayload
, retryFromDLQBatch
, retryDLQFiltered
, dlqJobExists
, deleteDLQJob
, deleteDLQJobsBatch
, listArchiveJobs
, getArchiveJobById
, listArchiveJobsByGroup
, deleteArchiveJob
, deleteArchiveJobsBatch
, reEnqueueFromArchive
, reEnqueueFromArchiveWithPayload
, listJobs
, getJobById
, jobExists
, listJobsByGroup
, listJobsByParent
, cancelJob
, cancelJobsBatch
, forceCancelJob
, promoteJob
, rescheduleJob
, Ops.QueueStats (..)
, Ops.QueueOverview (..)
, Ops.GroupSummary (..)
, getQueueStats
, countJobs
, countJobsByGroup
, countJobsByParent
, countDLQJobs
, countChildrenBatch
, countDLQChildren
, countDLQChildrenBatch
, pauseChildren
, resumeChildren
, cancelJobCascade
, suspendJob
, resumeJob
, insertResult
, insertResultUnsafe
, getResultsByParent
, getDLQChildErrorsByParent
, readChildResultsRaw
, Ops.mergeRawChildResults
, persistParentState
, getParentStateSnapshot
, refreshAllGroupsFully
, registerWorker
, heartbeatWorker
, setWorkerPaused
, markWorkerShuttingDown
, deregisterWorker
, listWorkers
, sweepStaleWorkers
, WorkerRow (..)
, WorkerHealth (..)
, ensureQueue
, setQueuePaused
, setQueueDLQRetention
, getQueue
, listQueues
, QueueRow (..)
, listCronSchedules
, getCronScheduleByName
, updateCronScheduleUnchecked
, CronScheduleRow (..)
, CronScheduleUpdate (..)
, runGated
, insertJobTree
, spawnChildren
, queueTable
, getSchema
) where
import Control.Monad (void, when)
import Data.Aeson (Value)
import Data.Foldable (toList)
import Data.Int (Int32, Int64)
import Data.List (genericLength)
import Data.List.NonEmpty (NonEmpty (..))
import Data.Map.Strict (Map)
import Data.Map.Strict qualified as Map
import Data.Proxy (Proxy (..))
import Data.Text (Text)
import Data.Text qualified as T
import Data.Time (NominalDiffTime, UTCTime)
import Data.UUID.Types (UUID)
import GHC.TypeLits (KnownSymbol, symbolVal)
import UnliftIO (MonadUnliftIO)
import Arbiter.Core.Admission (AdmissionPolicy (..))
import Arbiter.Core.Concurrency.Spec (ConcurrencyPolicy (..))
import Arbiter.Core.Concurrency.Stats (ConcurrencyKeyView, ConcurrencyPolicyUpdate (..), ConcurrencyPolicyView)
import Arbiter.Core.CronSchedule (CronScheduleRow (..), CronScheduleUpdate (..))
import Arbiter.Core.Job.Archive qualified as Archive
import Arbiter.Core.Job.DLQ qualified as DLQ
import Arbiter.Core.Job.Schema (SchemaName, TableName)
import Arbiter.Core.Job.Types
( ClaimSeq
, HasKind
, JobId
, JobPayload
, JobRead
, JobWrite
, RegistryAdmissionPolicies
, claimSeq
, claimedBy
, kindsFor
, primaryKey
)
import Arbiter.Core.Job.Types qualified as Job
import Arbiter.Core.JobResult (EncodeJobResult, encodeJobResult)
import Arbiter.Core.JobTree qualified as JT
import Arbiter.Core.MonadArbiter (MonadArbiter (..), ResultOf)
import Arbiter.Core.Operations qualified as Ops
import Arbiter.Core.QueueRegistry (RegistryTables (..), TableForPayload)
import Arbiter.Core.Queues (QueueRow (..))
import Arbiter.Core.RateLimit.Spec (RateLimitKey (..), RateLimitPolicy (..))
import Arbiter.Core.RateLimit.Stats (RateLimitBucketView, RateLimitPolicyUpdate (..), RateLimitPolicyView)
import Arbiter.Core.Trace (withPublishSpan)
import Arbiter.Core.Worker (WorkerHealth (..), WorkerRow (..))
type QueueOperation m payload =
( JobPayload payload
, KnownSymbol (TableForPayload payload (RegistryOf m))
, MonadArbiter m
)
type JobOperation m payload = (JobPayload payload, MonadArbiter m)
queueTable :: forall payload m. (KnownSymbol (TableForPayload payload (RegistryOf m))) => Text
queueTable :: forall payload (m :: * -> *).
KnownSymbol (TableForPayload payload (RegistryOf m)) =>
Text
queueTable = String -> Text
T.pack (String -> Text) -> String -> Text
forall a b. (a -> b) -> a -> b
$ Proxy (SpecName (MatchIn payload '[] (RegistryOf m))) -> String
forall (n :: Symbol) (proxy :: Symbol -> *).
KnownSymbol n =>
proxy n -> String
symbolVal (forall {k} (t :: k). Proxy t
forall (t :: Symbol). Proxy t
Proxy @(TableForPayload payload (RegistryOf m)))
onQueue
:: forall payload m a
. (KnownSymbol (TableForPayload payload (RegistryOf m)), MonadArbiter m)
=> (SchemaName -> TableName -> m a)
-> m a
onQueue :: forall payload (m :: * -> *) a.
(KnownSymbol (TableForPayload payload (RegistryOf m)),
MonadArbiter m) =>
(Text -> Text -> m a) -> m a
onQueue Text -> Text -> m a
operation = m Text
forall (m :: * -> *). MonadArbiter m => m Text
getSchema m Text -> (Text -> m a) -> m a
forall a b. m a -> (a -> m b) -> m b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Text
schemaName -> Text -> Text -> m a
operation Text
schemaName (forall payload (m :: * -> *).
KnownSymbol (TableForPayload payload (RegistryOf m)) =>
Text
queueTable @payload @m)
onSchema :: (MonadArbiter m) => (SchemaName -> m a) -> m a
onSchema :: forall (m :: * -> *) a. MonadArbiter m => (Text -> m a) -> m a
onSchema = (m Text
forall (m :: * -> *). MonadArbiter m => m Text
getSchema m Text -> (Text -> m a) -> m a
forall a b. m a -> (a -> m b) -> m b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>=)
onRegistry
:: forall m a
. (MonadArbiter m, RegistryTables (RegistryOf m))
=> (SchemaName -> [TableName] -> m a)
-> m a
onRegistry :: forall (m :: * -> *) a.
(MonadArbiter m, RegistryTables (RegistryOf m)) =>
(Text -> [Text] -> m a) -> m a
onRegistry Text -> [Text] -> m a
operation = m Text
forall (m :: * -> *). MonadArbiter m => m Text
getSchema m Text -> (Text -> m a) -> m a
forall a b. m a -> (a -> m b) -> m b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Text
schemaName -> Text -> [Text] -> m a
operation Text
schemaName (Proxy (RegistryOf m) -> [Text]
forall (registry :: JobPayloadRegistry).
RegistryTables registry =>
Proxy registry -> [Text]
registryTableNames (forall (t :: JobPayloadRegistry). Proxy t
forall {k} (t :: k). Proxy t
Proxy @(RegistryOf m)))
onJob :: (MonadArbiter m) => JobRead payload -> (SchemaName -> TableName -> m a) -> m a
onJob :: forall (m :: * -> *) payload a.
MonadArbiter m =>
JobRead payload -> (Text -> Text -> m a) -> m a
onJob JobRead payload
job Text -> Text -> m a
operation = m Text
forall (m :: * -> *). MonadArbiter m => m Text
getSchema m Text -> (Text -> m a) -> m a
forall a b. m a -> (a -> m b) -> m b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Text
schemaName -> Text -> Text -> m a
operation Text
schemaName (JobRead payload -> Text
forall payload key q insertedAt adm.
Job payload key q insertedAt adm -> q
Job.queueName JobRead payload
job)
onJobs :: (MonadArbiter m) => (item -> JobRead payload) -> a -> [item] -> (SchemaName -> TableName -> m a) -> m a
onJobs :: forall (m :: * -> *) item payload a.
MonadArbiter m =>
(item -> JobRead payload)
-> a -> [item] -> (Text -> Text -> m a) -> m a
onJobs item -> JobRead payload
_ a
none [] Text -> Text -> m a
_ = a -> m a
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure a
none
onJobs item -> JobRead payload
jobOf a
_ (item
item : [item]
_) Text -> Text -> m a
operation = JobRead payload -> (Text -> Text -> m a) -> m a
forall (m :: * -> *) payload a.
MonadArbiter m =>
JobRead payload -> (Text -> Text -> m a) -> m a
onJob (item -> JobRead payload
jobOf item
item) Text -> Text -> m a
operation
publishSpan
:: forall payload m a
. (HasKind payload, KnownSymbol (TableForPayload payload (RegistryOf m)), MonadUnliftIO m)
=> [JobWrite payload]
-> m a
-> m a
publishSpan :: forall payload (m :: * -> *) a.
(HasKind payload,
KnownSymbol (TableForPayload payload (RegistryOf m)),
MonadUnliftIO m) =>
[JobWrite payload] -> m a -> m a
publishSpan = Text -> [JobWrite payload] -> m a -> m a
forall payload (m :: * -> *) a.
(HasKind payload, MonadUnliftIO m) =>
Text -> [JobWrite payload] -> m a -> m a
withPublishSpan (forall payload (m :: * -> *).
KnownSymbol (TableForPayload payload (RegistryOf m)) =>
Text
queueTable @payload @m)
insertJob
:: forall payload m
. (QueueOperation m payload)
=> JobWrite payload
-> m (Maybe (JobRead payload))
insertJob :: forall payload (m :: * -> *).
QueueOperation m payload =>
JobWrite payload -> m (Maybe (JobRead payload))
insertJob JobWrite payload
job =
forall payload (m :: * -> *) a.
(HasKind payload,
KnownSymbol (TableForPayload payload (RegistryOf m)),
MonadUnliftIO m) =>
[JobWrite payload] -> m a -> m a
publishSpan @payload [JobWrite payload
job] (m (Maybe (JobRead payload)) -> m (Maybe (JobRead payload)))
-> m (Maybe (JobRead payload)) -> m (Maybe (JobRead payload))
forall a b. (a -> b) -> a -> b
$ forall payload (m :: * -> *) a.
(KnownSymbol (TableForPayload payload (RegistryOf m)),
MonadArbiter m) =>
(Text -> Text -> m a) -> m a
onQueue @payload ((Text -> Text -> m (Maybe (JobRead payload)))
-> m (Maybe (JobRead payload)))
-> (Text -> Text -> m (Maybe (JobRead payload)))
-> m (Maybe (JobRead payload))
forall a b. (a -> b) -> a -> b
$ \Text
schemaName Text
tableName ->
Text -> Text -> JobWrite payload -> m (Maybe (JobRead payload))
forall (m :: * -> *) payload.
(JobPayload payload, MonadArbiter m) =>
Text -> Text -> JobWrite payload -> m (Maybe (JobRead payload))
Ops.insertJob Text
schemaName Text
tableName JobWrite payload
job
insertJobsBatch
:: forall payload m
. (QueueOperation m payload)
=> [JobWrite payload]
-> m [JobRead payload]
insertJobsBatch :: forall payload (m :: * -> *).
QueueOperation m payload =>
[JobWrite payload] -> m [JobRead payload]
insertJobsBatch [] = [JobRead payload] -> m [JobRead payload]
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure []
insertJobsBatch [JobWrite payload]
jobs =
forall payload (m :: * -> *) a.
(HasKind payload,
KnownSymbol (TableForPayload payload (RegistryOf m)),
MonadUnliftIO m) =>
[JobWrite payload] -> m a -> m a
publishSpan @payload [JobWrite payload]
jobs (m [JobRead payload] -> m [JobRead payload])
-> m [JobRead payload] -> m [JobRead payload]
forall a b. (a -> b) -> a -> b
$ forall payload (m :: * -> *) a.
(KnownSymbol (TableForPayload payload (RegistryOf m)),
MonadArbiter m) =>
(Text -> Text -> m a) -> m a
onQueue @payload ((Text -> Text -> m [JobRead payload]) -> m [JobRead payload])
-> (Text -> Text -> m [JobRead payload]) -> m [JobRead payload]
forall a b. (a -> b) -> a -> b
$ \Text
schemaName Text
tableName ->
Text -> Text -> [JobWrite payload] -> m [JobRead payload]
forall (m :: * -> *) payload.
(JobPayload payload, MonadArbiter m) =>
Text -> Text -> [JobWrite payload] -> m [JobRead payload]
Ops.insertJobsBatch Text
schemaName Text
tableName [JobWrite payload]
jobs
insertJobsBatch_
:: forall payload m
. (QueueOperation m payload)
=> [JobWrite payload]
-> m Int64
insertJobsBatch_ :: forall payload (m :: * -> *).
QueueOperation m payload =>
[JobWrite payload] -> m Int64
insertJobsBatch_ [] = Int64 -> m Int64
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Int64
0
insertJobsBatch_ [JobWrite payload]
jobs =
forall payload (m :: * -> *) a.
(HasKind payload,
KnownSymbol (TableForPayload payload (RegistryOf m)),
MonadUnliftIO m) =>
[JobWrite payload] -> m a -> m a
publishSpan @payload [JobWrite payload]
jobs (m Int64 -> m Int64) -> m Int64 -> m Int64
forall a b. (a -> b) -> a -> b
$ forall payload (m :: * -> *) a.
(KnownSymbol (TableForPayload payload (RegistryOf m)),
MonadArbiter m) =>
(Text -> Text -> m a) -> m a
onQueue @payload ((Text -> Text -> m Int64) -> m Int64)
-> (Text -> Text -> m Int64) -> m Int64
forall a b. (a -> b) -> a -> b
$ \Text
schemaName Text
tableName ->
Text -> Text -> [JobWrite payload] -> m Int64
forall (m :: * -> *) payload.
(JobPayload payload, MonadArbiter m) =>
Text -> Text -> [JobWrite payload] -> m Int64
Ops.insertJobsBatch_ Text
schemaName Text
tableName [JobWrite payload]
jobs
claimNextVisibleJobs
:: forall payload m
. (QueueOperation m payload)
=> Int
-> NominalDiffTime
-> m [JobRead payload]
claimNextVisibleJobs :: forall payload (m :: * -> *).
QueueOperation m payload =>
Int -> NominalDiffTime -> m [JobRead payload]
claimNextVisibleJobs Int
limit NominalDiffTime
timeout =
forall payload (m :: * -> *) a.
(KnownSymbol (TableForPayload payload (RegistryOf m)),
MonadArbiter m) =>
(Text -> Text -> m a) -> m a
onQueue @payload ((Text -> Text -> m [JobRead payload]) -> m [JobRead payload])
-> (Text -> Text -> m [JobRead payload]) -> m [JobRead payload]
forall a b. (a -> b) -> a -> b
$ \Text
schemaName Text
tableName ->
Text -> Text -> Int -> NominalDiffTime -> m [JobRead payload]
forall (m :: * -> *) payload.
(JobPayload payload, MonadArbiter m) =>
Text -> Text -> Int -> NominalDiffTime -> m [JobRead payload]
Ops.claimNextVisibleJobs Text
schemaName Text
tableName Int
limit NominalDiffTime
timeout
claimNextVisibleJobsAs
:: forall payload m
. (QueueOperation m payload)
=> Int
-> NominalDiffTime
-> UUID
-> m [JobRead payload]
claimNextVisibleJobsAs :: forall payload (m :: * -> *).
QueueOperation m payload =>
Int -> NominalDiffTime -> UUID -> m [JobRead payload]
claimNextVisibleJobsAs Int
limit NominalDiffTime
timeout UUID
workerId =
forall payload (m :: * -> *) a.
(KnownSymbol (TableForPayload payload (RegistryOf m)),
MonadArbiter m) =>
(Text -> Text -> m a) -> m a
onQueue @payload ((Text -> Text -> m [JobRead payload]) -> m [JobRead payload])
-> (Text -> Text -> m [JobRead payload]) -> m [JobRead payload]
forall a b. (a -> b) -> a -> b
$ \Text
schemaName Text
tableName ->
Text
-> Text -> Int -> NominalDiffTime -> UUID -> m [JobRead payload]
forall (m :: * -> *) payload.
(JobPayload payload, MonadArbiter m) =>
Text
-> Text -> Int -> NominalDiffTime -> UUID -> m [JobRead payload]
Ops.claimNextVisibleJobsAs Text
schemaName Text
tableName Int
limit NominalDiffTime
timeout UUID
workerId
claimNextVisibleJobsBatched
:: forall payload m
. (QueueOperation m payload)
=> Int
-> Int
-> NominalDiffTime
-> m [NonEmpty (JobRead payload)]
claimNextVisibleJobsBatched :: forall payload (m :: * -> *).
QueueOperation m payload =>
Int -> Int -> NominalDiffTime -> m [NonEmpty (JobRead payload)]
claimNextVisibleJobsBatched Int
batchSize Int
maxBatches NominalDiffTime
timeout =
forall payload (m :: * -> *) a.
(KnownSymbol (TableForPayload payload (RegistryOf m)),
MonadArbiter m) =>
(Text -> Text -> m a) -> m a
onQueue @payload ((Text -> Text -> m [NonEmpty (JobRead payload)])
-> m [NonEmpty (JobRead payload)])
-> (Text -> Text -> m [NonEmpty (JobRead payload)])
-> m [NonEmpty (JobRead payload)]
forall a b. (a -> b) -> a -> b
$ \Text
schemaName Text
tableName ->
Text
-> Text
-> Int
-> Int
-> NominalDiffTime
-> m [NonEmpty (JobRead payload)]
forall (m :: * -> *) payload.
(JobPayload payload, MonadArbiter m) =>
Text
-> Text
-> Int
-> Int
-> NominalDiffTime
-> m [NonEmpty (JobRead payload)]
Ops.claimNextVisibleJobsBatched Text
schemaName Text
tableName Int
batchSize Int
maxBatches NominalDiffTime
timeout
ackJob
:: forall payload m
. (MonadArbiter m)
=> JobRead payload
-> m Int64
ackJob :: forall payload (m :: * -> *).
MonadArbiter m =>
JobRead payload -> m Int64
ackJob JobRead payload
job = JobRead payload -> (Text -> Text -> m Int64) -> m Int64
forall (m :: * -> *) payload a.
MonadArbiter m =>
JobRead payload -> (Text -> Text -> m a) -> m a
onJob JobRead payload
job ((Text -> Text -> m Int64) -> m Int64)
-> (Text -> Text -> m Int64) -> m Int64
forall a b. (a -> b) -> a -> b
$ \Text
schemaName Text
tableName -> Text -> Text -> JobRead payload -> m Int64
forall (m :: * -> *) payload.
MonadArbiter m =>
Text -> Text -> JobRead payload -> m Int64
Ops.ackJob Text
schemaName Text
tableName JobRead payload
job
ackJobsBatch
:: forall payload m
. (MonadArbiter m)
=> [JobRead payload]
-> m [Int64]
ackJobsBatch :: forall payload (m :: * -> *).
MonadArbiter m =>
[JobRead payload] -> m [Int64]
ackJobsBatch [JobRead payload]
jobs = (JobRead payload -> JobRead payload)
-> [Int64]
-> [JobRead payload]
-> (Text -> Text -> m [Int64])
-> m [Int64]
forall (m :: * -> *) item payload a.
MonadArbiter m =>
(item -> JobRead payload)
-> a -> [item] -> (Text -> Text -> m a) -> m a
onJobs JobRead payload -> JobRead payload
forall a. a -> a
id [] [JobRead payload]
jobs ((Text -> Text -> m [Int64]) -> m [Int64])
-> (Text -> Text -> m [Int64]) -> m [Int64]
forall a b. (a -> b) -> a -> b
$ \Text
schemaName Text
tableName -> Text -> Text -> [JobRead payload] -> m [Int64]
forall (m :: * -> *) payload.
MonadArbiter m =>
Text -> Text -> [JobRead payload] -> m [Int64]
Ops.ackJobsBatch Text
schemaName Text
tableName [JobRead payload]
jobs
updateJobForRetry
:: forall payload m
. (MonadArbiter m)
=> NominalDiffTime
-> Text
-> JobRead payload
-> m Int64
updateJobForRetry :: forall payload (m :: * -> *).
MonadArbiter m =>
NominalDiffTime -> Text -> JobRead payload -> m Int64
updateJobForRetry NominalDiffTime
delay Text
errorMsg JobRead payload
job =
JobRead payload -> (Text -> Text -> m Int64) -> m Int64
forall (m :: * -> *) payload a.
MonadArbiter m =>
JobRead payload -> (Text -> Text -> m a) -> m a
onJob JobRead payload
job ((Text -> Text -> m Int64) -> m Int64)
-> (Text -> Text -> m Int64) -> m Int64
forall a b. (a -> b) -> a -> b
$ \Text
schemaName Text
tableName -> Text
-> Text -> NominalDiffTime -> Text -> JobRead payload -> m Int64
forall (m :: * -> *) payload.
MonadArbiter m =>
Text
-> Text -> NominalDiffTime -> Text -> JobRead payload -> m Int64
Ops.updateJobForRetry Text
schemaName Text
tableName NominalDiffTime
delay Text
errorMsg JobRead payload
job
nackJob
:: forall payload m
. (MonadArbiter m)
=> JobRead payload
-> m Int64
nackJob :: forall payload (m :: * -> *).
MonadArbiter m =>
JobRead payload -> m Int64
nackJob JobRead payload
job = JobRead payload -> (Text -> Text -> m Int64) -> m Int64
forall (m :: * -> *) payload a.
MonadArbiter m =>
JobRead payload -> (Text -> Text -> m a) -> m a
onJob JobRead payload
job ((Text -> Text -> m Int64) -> m Int64)
-> (Text -> Text -> m Int64) -> m Int64
forall a b. (a -> b) -> a -> b
$ \Text
schemaName Text
tableName -> Text -> Text -> Maybe NominalDiffTime -> JobRead payload -> m Int64
forall (m :: * -> *) payload.
MonadArbiter m =>
Text -> Text -> Maybe NominalDiffTime -> JobRead payload -> m Int64
Ops.nackJob Text
schemaName Text
tableName Maybe NominalDiffTime
forall a. Maybe a
Nothing JobRead payload
job
nackJobAfter
:: forall payload m
. (MonadArbiter m)
=> NominalDiffTime
-> JobRead payload
-> m Int64
nackJobAfter :: forall payload (m :: * -> *).
MonadArbiter m =>
NominalDiffTime -> JobRead payload -> m Int64
nackJobAfter NominalDiffTime
delay JobRead payload
job = JobRead payload -> (Text -> Text -> m Int64) -> m Int64
forall (m :: * -> *) payload a.
MonadArbiter m =>
JobRead payload -> (Text -> Text -> m a) -> m a
onJob JobRead payload
job ((Text -> Text -> m Int64) -> m Int64)
-> (Text -> Text -> m Int64) -> m Int64
forall a b. (a -> b) -> a -> b
$ \Text
schemaName Text
tableName -> Text -> Text -> Maybe NominalDiffTime -> JobRead payload -> m Int64
forall (m :: * -> *) payload.
MonadArbiter m =>
Text -> Text -> Maybe NominalDiffTime -> JobRead payload -> m Int64
Ops.nackJob Text
schemaName Text
tableName (NominalDiffTime -> Maybe NominalDiffTime
forall a. a -> Maybe a
Just NominalDiffTime
delay) JobRead payload
job
nackJobsBatch
:: forall payload m
. (MonadArbiter m)
=> [JobRead payload]
-> m [Int64]
nackJobsBatch :: forall payload (m :: * -> *).
MonadArbiter m =>
[JobRead payload] -> m [Int64]
nackJobsBatch [JobRead payload]
jobs = (JobRead payload -> JobRead payload)
-> [Int64]
-> [JobRead payload]
-> (Text -> Text -> m [Int64])
-> m [Int64]
forall (m :: * -> *) item payload a.
MonadArbiter m =>
(item -> JobRead payload)
-> a -> [item] -> (Text -> Text -> m a) -> m a
onJobs JobRead payload -> JobRead payload
forall a. a -> a
id [] [JobRead payload]
jobs ((Text -> Text -> m [Int64]) -> m [Int64])
-> (Text -> Text -> m [Int64]) -> m [Int64]
forall a b. (a -> b) -> a -> b
$ \Text
schemaName Text
tableName -> Text
-> Text -> Maybe NominalDiffTime -> [JobRead payload] -> m [Int64]
forall (m :: * -> *) payload.
MonadArbiter m =>
Text
-> Text -> Maybe NominalDiffTime -> [JobRead payload] -> m [Int64]
Ops.nackJobsBatch Text
schemaName Text
tableName Maybe NominalDiffTime
forall a. Maybe a
Nothing [JobRead payload]
jobs
nackJobsBatchAfter
:: forall payload m
. (MonadArbiter m)
=> NominalDiffTime
-> [JobRead payload]
-> m [Int64]
nackJobsBatchAfter :: forall payload (m :: * -> *).
MonadArbiter m =>
NominalDiffTime -> [JobRead payload] -> m [Int64]
nackJobsBatchAfter NominalDiffTime
delay [JobRead payload]
jobs =
(JobRead payload -> JobRead payload)
-> [Int64]
-> [JobRead payload]
-> (Text -> Text -> m [Int64])
-> m [Int64]
forall (m :: * -> *) item payload a.
MonadArbiter m =>
(item -> JobRead payload)
-> a -> [item] -> (Text -> Text -> m a) -> m a
onJobs JobRead payload -> JobRead payload
forall a. a -> a
id [] [JobRead payload]
jobs ((Text -> Text -> m [Int64]) -> m [Int64])
-> (Text -> Text -> m [Int64]) -> m [Int64]
forall a b. (a -> b) -> a -> b
$ \Text
schemaName Text
tableName -> Text
-> Text -> Maybe NominalDiffTime -> [JobRead payload] -> m [Int64]
forall (m :: * -> *) payload.
MonadArbiter m =>
Text
-> Text -> Maybe NominalDiffTime -> [JobRead payload] -> m [Int64]
Ops.nackJobsBatch Text
schemaName Text
tableName (NominalDiffTime -> Maybe NominalDiffTime
forall a. a -> Maybe a
Just NominalDiffTime
delay) [JobRead payload]
jobs
setVisibilityTimeout
:: forall payload m
. (MonadArbiter m)
=> NominalDiffTime
-> JobRead payload
-> m Int64
setVisibilityTimeout :: forall payload (m :: * -> *).
MonadArbiter m =>
NominalDiffTime -> JobRead payload -> m Int64
setVisibilityTimeout NominalDiffTime
timeout JobRead payload
job =
JobRead payload -> (Text -> Text -> m Int64) -> m Int64
forall (m :: * -> *) payload a.
MonadArbiter m =>
JobRead payload -> (Text -> Text -> m a) -> m a
onJob JobRead payload
job ((Text -> Text -> m Int64) -> m Int64)
-> (Text -> Text -> m Int64) -> m Int64
forall a b. (a -> b) -> a -> b
$ \Text
schemaName Text
tableName ->
Text -> Text -> NominalDiffTime -> JobRead payload -> m Int64
forall (m :: * -> *) payload.
MonadArbiter m =>
Text -> Text -> NominalDiffTime -> JobRead payload -> m Int64
Ops.setVisibilityTimeout Text
schemaName Text
tableName NominalDiffTime
timeout JobRead payload
job
setVisibilityTimeoutBatch
:: forall payload m
. (MonadArbiter m)
=> NominalDiffTime
-> [JobRead payload]
-> m [SetVisibilityResult]
setVisibilityTimeoutBatch :: forall payload (m :: * -> *).
MonadArbiter m =>
NominalDiffTime -> [JobRead payload] -> m [SetVisibilityResult]
setVisibilityTimeoutBatch NominalDiffTime
timeout [JobRead payload]
jobs =
(JobRead payload -> JobRead payload)
-> [SetVisibilityResult]
-> [JobRead payload]
-> (Text -> Text -> m [SetVisibilityResult])
-> m [SetVisibilityResult]
forall (m :: * -> *) item payload a.
MonadArbiter m =>
(item -> JobRead payload)
-> a -> [item] -> (Text -> Text -> m a) -> m a
onJobs JobRead payload -> JobRead payload
forall a. a -> a
id [] [JobRead payload]
jobs ((Text -> Text -> m [SetVisibilityResult])
-> m [SetVisibilityResult])
-> (Text -> Text -> m [SetVisibilityResult])
-> m [SetVisibilityResult]
forall a b. (a -> b) -> a -> b
$ \Text
schemaName Text
tableName ->
(VisibilityUpdateInfo -> SetVisibilityResult)
-> [VisibilityUpdateInfo] -> [SetVisibilityResult]
forall a b. (a -> b) -> [a] -> [b]
map VisibilityUpdateInfo -> SetVisibilityResult
toResult ([VisibilityUpdateInfo] -> [SetVisibilityResult])
-> m [VisibilityUpdateInfo] -> m [SetVisibilityResult]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Text
-> Text
-> NominalDiffTime
-> [JobRead payload]
-> m [VisibilityUpdateInfo]
forall (m :: * -> *) payload.
MonadArbiter m =>
Text
-> Text
-> NominalDiffTime
-> [JobRead payload]
-> m [VisibilityUpdateInfo]
Ops.setVisibilityTimeoutBatch Text
schemaName Text
tableName NominalDiffTime
timeout [JobRead payload]
jobs
where
jobMap :: Map Int64 (JobRead payload)
jobMap = [(Int64, JobRead payload)] -> Map Int64 (JobRead payload)
forall k a. Ord k => [(k, a)] -> Map k a
Map.fromList [(JobRead payload -> Int64
forall payload key q insertedAt adm.
Job payload key q insertedAt adm -> key
primaryKey JobRead payload
job, JobRead payload
job) | JobRead payload
job <- [JobRead payload]
jobs]
toResult :: VisibilityUpdateInfo -> SetVisibilityResult
toResult
Ops.VisibilityUpdateInfo
{ vuiJobId :: VisibilityUpdateInfo -> Int64
Ops.vuiJobId = Int64
jobId
, vuiWasHeartbeated :: VisibilityUpdateInfo -> Bool
Ops.vuiWasHeartbeated = Bool
heartbeated
, vuiCurrentDbClaimSeq :: VisibilityUpdateInfo -> Maybe Int64
Ops.vuiCurrentDbClaimSeq = Maybe Int64
mActual
, vuiCancelRequested :: VisibilityUpdateInfo -> Bool
Ops.vuiCancelRequested = Bool
cancelled
, vuiSuspended :: VisibilityUpdateInfo -> Bool
Ops.vuiSuspended = Bool
suspended
, vuiClaimedBy :: VisibilityUpdateInfo -> Maybe UUID
Ops.vuiClaimedBy = Maybe UUID
holder
} =
let mJob :: Maybe (JobRead payload)
mJob = Int64 -> Map Int64 (JobRead payload) -> Maybe (JobRead payload)
forall k a. Ord k => k -> Map k a -> Maybe a
Map.lookup Int64
jobId Map Int64 (JobRead payload)
jobMap
expected :: Int64
expected = Int64
-> (JobRead payload -> Int64) -> Maybe (JobRead payload) -> Int64
forall b a. b -> (a -> b) -> Maybe a -> b
maybe Int64
0 JobRead payload -> Int64
forall payload q insertedAt adm.
Job payload Int64 q insertedAt adm -> Int64
claimSeq Maybe (JobRead payload)
mJob
heldHere :: Bool
heldHere = (JobRead payload -> Bool) -> Maybe (JobRead payload) -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
any ((Maybe UUID -> Maybe UUID -> Bool
forall a. Eq a => a -> a -> Bool
== Maybe UUID
holder) (Maybe UUID -> Bool)
-> (JobRead payload -> Maybe UUID) -> JobRead payload -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. JobRead payload -> Maybe UUID
forall payload q insertedAt adm.
Job payload Int64 q insertedAt adm -> Maybe UUID
claimedBy) Maybe (JobRead payload)
mJob
in case Maybe Int64
mActual of
Maybe Int64
Nothing -> Int64 -> SetVisibilityResult
JobGone Int64
jobId
Just Int64
actual
| Bool
cancelled, Bool
heldHere, Int64
actual Int64 -> Int64 -> Bool
forall a. Eq a => a -> a -> Bool
== Int64
expected Int64 -> Int64 -> Int64
forall a. Num a => a -> a -> a
+ Int64
Ops.cancelTokenBump -> Int64 -> SetVisibilityResult
JobCancelled Int64
jobId
| Int64
actual Int64 -> Int64 -> Bool
forall a. Eq a => a -> a -> Bool
/= Int64
expected -> Int64 -> Int64 -> Int64 -> SetVisibilityResult
JobReclaimed Int64
jobId Int64
expected Int64
actual
| Bool
suspended -> Int64 -> SetVisibilityResult
JobSuspended Int64
jobId
| Bool
heartbeated -> Int64 -> SetVisibilityResult
VisibilityExtended Int64
jobId
| Bool
otherwise -> Int64 -> SetVisibilityResult
VisibilityUnchanged Int64
jobId
data SetVisibilityResult
=
VisibilityExtended JobId
|
JobGone JobId
|
JobReclaimed JobId ClaimSeq ClaimSeq
|
JobCancelled JobId
|
JobSuspended JobId
|
VisibilityUnchanged JobId
deriving stock (SetVisibilityResult -> SetVisibilityResult -> Bool
(SetVisibilityResult -> SetVisibilityResult -> Bool)
-> (SetVisibilityResult -> SetVisibilityResult -> Bool)
-> Eq SetVisibilityResult
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SetVisibilityResult -> SetVisibilityResult -> Bool
== :: SetVisibilityResult -> SetVisibilityResult -> Bool
$c/= :: SetVisibilityResult -> SetVisibilityResult -> Bool
/= :: SetVisibilityResult -> SetVisibilityResult -> Bool
Eq, Int -> SetVisibilityResult -> ShowS
[SetVisibilityResult] -> ShowS
SetVisibilityResult -> String
(Int -> SetVisibilityResult -> ShowS)
-> (SetVisibilityResult -> String)
-> ([SetVisibilityResult] -> ShowS)
-> Show SetVisibilityResult
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SetVisibilityResult -> ShowS
showsPrec :: Int -> SetVisibilityResult -> ShowS
$cshow :: SetVisibilityResult -> String
show :: SetVisibilityResult -> String
$cshowList :: [SetVisibilityResult] -> ShowS
showList :: [SetVisibilityResult] -> ShowS
Show)
addRateLimitTokens
:: forall m
. (MonadArbiter m, RegistryTables (RegistryOf m))
=> RateLimitKey
-> Double
-> m Int64
addRateLimitTokens :: forall (m :: * -> *).
(MonadArbiter m, RegistryTables (RegistryOf m)) =>
RateLimitKey -> Double -> m Int64
addRateLimitTokens RateLimitKey
key Double
amount =
m Int64 -> m Int64
forall a. m a -> m a
forall (m :: * -> *) a. MonadArbiter m => m a -> m a
withDbTransaction (m Int64 -> m Int64) -> m Int64 -> m Int64
forall a b. (a -> b) -> a -> b
$ (Text -> [Text] -> m Int64) -> m Int64
forall (m :: * -> *) a.
(MonadArbiter m, RegistryTables (RegistryOf m)) =>
(Text -> [Text] -> m a) -> m a
onRegistry ((Text -> [Text] -> m Int64) -> m Int64)
-> (Text -> [Text] -> m Int64) -> m Int64
forall a b. (a -> b) -> a -> b
$ \Text
schemaName [Text]
queues ->
Text -> RateLimitKey -> Double -> m ()
forall (m :: * -> *).
MonadArbiter m =>
Text -> RateLimitKey -> Double -> m ()
Ops.addRateLimitTokens Text
schemaName RateLimitKey
key Double
amount m () -> m Int64 -> m Int64
forall a b. m a -> m b -> m b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Text -> [Text] -> RateLimitKey -> m Int64
forall (m :: * -> *).
MonadArbiter m =>
Text -> [Text] -> RateLimitKey -> m Int64
Ops.wakeThrottledJobsForKey Text
schemaName [Text]
queues RateLimitKey
key
pruneRateLimitBuckets
:: forall m
. (MonadArbiter m)
=> NominalDiffTime
-> m Int64
pruneRateLimitBuckets :: forall (m :: * -> *). MonadArbiter m => NominalDiffTime -> m Int64
pruneRateLimitBuckets NominalDiffTime
idle = (Text -> m Int64) -> m Int64
forall (m :: * -> *) a. MonadArbiter m => (Text -> m a) -> m a
onSchema ((Text -> m Int64) -> m Int64) -> (Text -> m Int64) -> m Int64
forall a b. (a -> b) -> a -> b
$ \Text
schemaName -> Text -> NominalDiffTime -> m Int64
forall (m :: * -> *).
MonadArbiter m =>
Text -> NominalDiffTime -> m Int64
Ops.pruneRateLimitBuckets Text
schemaName NominalDiffTime
idle
resetRateLimitBuckets
:: forall m
. (MonadArbiter m, RegistryTables (RegistryOf m))
=> Text
-> m Int64
resetRateLimitBuckets :: forall (m :: * -> *).
(MonadArbiter m, RegistryTables (RegistryOf m)) =>
Text -> m Int64
resetRateLimitBuckets Text
prefix =
m Int64 -> m Int64
forall a. m a -> m a
forall (m :: * -> *) a. MonadArbiter m => m a -> m a
withDbTransaction (m Int64 -> m Int64) -> m Int64 -> m Int64
forall a b. (a -> b) -> a -> b
$ (Text -> [Text] -> m Int64) -> m Int64
forall (m :: * -> *) a.
(MonadArbiter m, RegistryTables (RegistryOf m)) =>
(Text -> [Text] -> m a) -> m a
onRegistry ((Text -> [Text] -> m Int64) -> m Int64)
-> (Text -> [Text] -> m Int64) -> m Int64
forall a b. (a -> b) -> a -> b
$ \Text
schemaName [Text]
queues ->
Text -> Text -> m Int64
forall (m :: * -> *). MonadArbiter m => Text -> Text -> m Int64
Ops.resetRateLimitBuckets Text
schemaName Text
prefix m Int64 -> m Int64 -> m Int64
forall a b. m a -> m b -> m a
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* Text -> [Text] -> Text -> m Int64
forall (m :: * -> *).
MonadArbiter m =>
Text -> [Text] -> Text -> m Int64
Ops.wakeThrottledJobs Text
schemaName [Text]
queues Text
prefix
listRateLimitPolicies
:: forall m
. (MonadArbiter m, RegistryTables (RegistryOf m))
=> m [RateLimitPolicyView]
listRateLimitPolicies :: forall (m :: * -> *).
(MonadArbiter m, RegistryTables (RegistryOf m)) =>
m [RateLimitPolicyView]
listRateLimitPolicies = (Text -> [Text] -> m [RateLimitPolicyView])
-> m [RateLimitPolicyView]
forall (m :: * -> *) a.
(MonadArbiter m, RegistryTables (RegistryOf m)) =>
(Text -> [Text] -> m a) -> m a
onRegistry Text -> [Text] -> m [RateLimitPolicyView]
forall (m :: * -> *).
MonadArbiter m =>
Text -> [Text] -> m [RateLimitPolicyView]
Ops.listRateLimitPolicies
getRateLimitPolicy
:: forall m
. (MonadArbiter m, RegistryTables (RegistryOf m))
=> Text
-> m (Maybe RateLimitPolicyView)
getRateLimitPolicy :: forall (m :: * -> *).
(MonadArbiter m, RegistryTables (RegistryOf m)) =>
Text -> m (Maybe RateLimitPolicyView)
getRateLimitPolicy Text
prefix = (Text -> [Text] -> m (Maybe RateLimitPolicyView))
-> m (Maybe RateLimitPolicyView)
forall (m :: * -> *) a.
(MonadArbiter m, RegistryTables (RegistryOf m)) =>
(Text -> [Text] -> m a) -> m a
onRegistry ((Text -> [Text] -> m (Maybe RateLimitPolicyView))
-> m (Maybe RateLimitPolicyView))
-> (Text -> [Text] -> m (Maybe RateLimitPolicyView))
-> m (Maybe RateLimitPolicyView)
forall a b. (a -> b) -> a -> b
$ \Text
schemaName [Text]
queues -> Text -> [Text] -> Text -> m (Maybe RateLimitPolicyView)
forall (m :: * -> *).
MonadArbiter m =>
Text -> [Text] -> Text -> m (Maybe RateLimitPolicyView)
Ops.getRateLimitPolicy Text
schemaName [Text]
queues Text
prefix
rateLimitPolicyExists
:: forall m
. (MonadArbiter m)
=> Text
-> m Bool
rateLimitPolicyExists :: forall (m :: * -> *). MonadArbiter m => Text -> m Bool
rateLimitPolicyExists Text
prefix = (Text -> m Bool) -> m Bool
forall (m :: * -> *) a. MonadArbiter m => (Text -> m a) -> m a
onSchema ((Text -> m Bool) -> m Bool) -> (Text -> m Bool) -> m Bool
forall a b. (a -> b) -> a -> b
$ \Text
schemaName -> Text -> Text -> m Bool
forall (m :: * -> *). MonadArbiter m => Text -> Text -> m Bool
Ops.rateLimitPolicyExists Text
schemaName Text
prefix
listRateLimitBuckets
:: forall m
. (MonadArbiter m)
=> Text
-> Int
-> Int
-> m [RateLimitBucketView]
listRateLimitBuckets :: forall (m :: * -> *).
MonadArbiter m =>
Text -> Int -> Int -> m [RateLimitBucketView]
listRateLimitBuckets Text
prefix Int
limit Int
offset =
(Text -> m [RateLimitBucketView]) -> m [RateLimitBucketView]
forall (m :: * -> *) a. MonadArbiter m => (Text -> m a) -> m a
onSchema ((Text -> m [RateLimitBucketView]) -> m [RateLimitBucketView])
-> (Text -> m [RateLimitBucketView]) -> m [RateLimitBucketView]
forall a b. (a -> b) -> a -> b
$ \Text
schemaName ->
Text -> Text -> Int -> Int -> m [RateLimitBucketView]
forall (m :: * -> *).
MonadArbiter m =>
Text -> Text -> Int -> Int -> m [RateLimitBucketView]
Ops.listRateLimitBuckets Text
schemaName Text
prefix Int
limit Int
offset
updateRateLimitPolicyOverrides
:: forall m
. (MonadArbiter m, RegistryTables (RegistryOf m))
=> Text
-> RateLimitPolicyUpdate
-> m Int64
updateRateLimitPolicyOverrides :: forall (m :: * -> *).
(MonadArbiter m, RegistryTables (RegistryOf m)) =>
Text -> RateLimitPolicyUpdate -> m Int64
updateRateLimitPolicyOverrides Text
prefix RateLimitPolicyUpdate
upd = (Text -> [Text] -> m Int64) -> m Int64
forall (m :: * -> *) a.
(MonadArbiter m, RegistryTables (RegistryOf m)) =>
(Text -> [Text] -> m a) -> m a
onRegistry ((Text -> [Text] -> m Int64) -> m Int64)
-> (Text -> [Text] -> m Int64) -> m Int64
forall a b. (a -> b) -> a -> b
$ \Text
schemaName [Text]
queues -> do
affected <- Text -> Text -> RateLimitPolicyUpdate -> m Int64
forall (m :: * -> *).
MonadArbiter m =>
Text -> Text -> RateLimitPolicyUpdate -> m Int64
Ops.updateRateLimitPolicyOverrides Text
schemaName Text
prefix RateLimitPolicyUpdate
upd
when (affected > 0) $ void $ Ops.wakeThrottledJobs schemaName queues prefix
pure affected
setRateLimit :: (MonadArbiter m, RegistryTables (RegistryOf m)) => RateLimitPolicy -> m Int64
setRateLimit :: forall (m :: * -> *).
(MonadArbiter m, RegistryTables (RegistryOf m)) =>
RateLimitPolicy -> m Int64
setRateLimit RateLimitPolicy
policy =
Text -> RateLimitPolicyUpdate -> m Int64
forall (m :: * -> *).
(MonadArbiter m, RegistryTables (RegistryOf m)) =>
Text -> RateLimitPolicyUpdate -> m Int64
updateRateLimitPolicyOverrides (RateLimitPolicy -> Text
forall p. AdmissionPolicy p => p -> Text
policyPrefixOf RateLimitPolicy
policy) (RateLimitPolicyUpdate -> m Int64)
-> RateLimitPolicyUpdate -> m Int64
forall a b. (a -> b) -> a -> b
$
RateLimitPolicyUpdate
{ overrideMaxTokens :: Maybe (Maybe Double)
overrideMaxTokens = Maybe Double -> Maybe (Maybe Double)
forall a. a -> Maybe a
Just (Double -> Maybe Double
forall a. a -> Maybe a
Just (RateLimitPolicy -> Double
policyMax RateLimitPolicy
policy))
, overrideRefillAmount :: Maybe (Maybe Double)
overrideRefillAmount = Maybe Double -> Maybe (Maybe Double)
forall a. a -> Maybe a
Just (Double -> Maybe Double
forall a. a -> Maybe a
Just (RateLimitPolicy -> Double
policyRefill RateLimitPolicy
policy))
, overrideInterval :: Maybe (Maybe Double)
overrideInterval = Maybe Double -> Maybe (Maybe Double)
forall a. a -> Maybe a
Just (Double -> Maybe Double
forall a. a -> Maybe a
Just (NominalDiffTime -> Double
forall a b. (Real a, Fractional b) => a -> b
realToFrac (RateLimitPolicy -> NominalDiffTime
policyInterval RateLimitPolicy
policy)))
}
clearRateLimit :: (MonadArbiter m, RegistryTables (RegistryOf m)) => RateLimitPolicy -> m Int64
clearRateLimit :: forall (m :: * -> *).
(MonadArbiter m, RegistryTables (RegistryOf m)) =>
RateLimitPolicy -> m Int64
clearRateLimit RateLimitPolicy
policy =
Text -> RateLimitPolicyUpdate -> m Int64
forall (m :: * -> *).
(MonadArbiter m, RegistryTables (RegistryOf m)) =>
Text -> RateLimitPolicyUpdate -> m Int64
updateRateLimitPolicyOverrides (RateLimitPolicy -> Text
forall p. AdmissionPolicy p => p -> Text
policyPrefixOf RateLimitPolicy
policy) (RateLimitPolicyUpdate -> m Int64)
-> RateLimitPolicyUpdate -> m Int64
forall a b. (a -> b) -> a -> b
$
RateLimitPolicyUpdate
{ overrideMaxTokens :: Maybe (Maybe Double)
overrideMaxTokens = Maybe Double -> Maybe (Maybe Double)
forall a. a -> Maybe a
Just Maybe Double
forall a. Maybe a
Nothing
, overrideRefillAmount :: Maybe (Maybe Double)
overrideRefillAmount = Maybe Double -> Maybe (Maybe Double)
forall a. a -> Maybe a
Just Maybe Double
forall a. Maybe a
Nothing
, overrideInterval :: Maybe (Maybe Double)
overrideInterval = Maybe Double -> Maybe (Maybe Double)
forall a. a -> Maybe a
Just Maybe Double
forall a. Maybe a
Nothing
}
listConcurrencyPolicies
:: forall m
. (MonadArbiter m)
=> m [ConcurrencyPolicyView]
listConcurrencyPolicies :: forall (m :: * -> *). MonadArbiter m => m [ConcurrencyPolicyView]
listConcurrencyPolicies = (Text -> m [ConcurrencyPolicyView]) -> m [ConcurrencyPolicyView]
forall (m :: * -> *) a. MonadArbiter m => (Text -> m a) -> m a
onSchema Text -> m [ConcurrencyPolicyView]
forall (m :: * -> *).
MonadArbiter m =>
Text -> m [ConcurrencyPolicyView]
Ops.listConcurrencyPolicies
getConcurrencyPolicy
:: forall m
. (MonadArbiter m)
=> Text
-> m (Maybe ConcurrencyPolicyView)
getConcurrencyPolicy :: forall (m :: * -> *).
MonadArbiter m =>
Text -> m (Maybe ConcurrencyPolicyView)
getConcurrencyPolicy Text
prefix = (Text -> m (Maybe ConcurrencyPolicyView))
-> m (Maybe ConcurrencyPolicyView)
forall (m :: * -> *) a. MonadArbiter m => (Text -> m a) -> m a
onSchema ((Text -> m (Maybe ConcurrencyPolicyView))
-> m (Maybe ConcurrencyPolicyView))
-> (Text -> m (Maybe ConcurrencyPolicyView))
-> m (Maybe ConcurrencyPolicyView)
forall a b. (a -> b) -> a -> b
$ \Text
schemaName -> Text -> Text -> m (Maybe ConcurrencyPolicyView)
forall (m :: * -> *).
MonadArbiter m =>
Text -> Text -> m (Maybe ConcurrencyPolicyView)
Ops.getConcurrencyPolicy Text
schemaName Text
prefix
concurrencyPolicyExists
:: forall m
. (MonadArbiter m)
=> Text
-> m Bool
concurrencyPolicyExists :: forall (m :: * -> *). MonadArbiter m => Text -> m Bool
concurrencyPolicyExists Text
prefix = (Text -> m Bool) -> m Bool
forall (m :: * -> *) a. MonadArbiter m => (Text -> m a) -> m a
onSchema ((Text -> m Bool) -> m Bool) -> (Text -> m Bool) -> m Bool
forall a b. (a -> b) -> a -> b
$ \Text
schemaName -> Text -> Text -> m Bool
forall (m :: * -> *). MonadArbiter m => Text -> Text -> m Bool
Ops.concurrencyPolicyExists Text
schemaName Text
prefix
listConcurrencyKeys
:: forall m
. (MonadArbiter m)
=> Text
-> Int
-> Int
-> m [ConcurrencyKeyView]
listConcurrencyKeys :: forall (m :: * -> *).
MonadArbiter m =>
Text -> Int -> Int -> m [ConcurrencyKeyView]
listConcurrencyKeys Text
prefix Int
limit Int
offset =
(Text -> m [ConcurrencyKeyView]) -> m [ConcurrencyKeyView]
forall (m :: * -> *) a. MonadArbiter m => (Text -> m a) -> m a
onSchema ((Text -> m [ConcurrencyKeyView]) -> m [ConcurrencyKeyView])
-> (Text -> m [ConcurrencyKeyView]) -> m [ConcurrencyKeyView]
forall a b. (a -> b) -> a -> b
$ \Text
schemaName ->
Text -> Text -> Int -> Int -> m [ConcurrencyKeyView]
forall (m :: * -> *).
MonadArbiter m =>
Text -> Text -> Int -> Int -> m [ConcurrencyKeyView]
Ops.listConcurrencyKeys Text
schemaName Text
prefix Int
limit Int
offset
updateConcurrencyPolicyOverrides
:: forall m
. (MonadArbiter m)
=> Text
-> ConcurrencyPolicyUpdate
-> m Int64
updateConcurrencyPolicyOverrides :: forall (m :: * -> *).
MonadArbiter m =>
Text -> ConcurrencyPolicyUpdate -> m Int64
updateConcurrencyPolicyOverrides Text
prefix ConcurrencyPolicyUpdate
upd =
(Text -> m Int64) -> m Int64
forall (m :: * -> *) a. MonadArbiter m => (Text -> m a) -> m a
onSchema ((Text -> m Int64) -> m Int64) -> (Text -> m Int64) -> m Int64
forall a b. (a -> b) -> a -> b
$ \Text
schemaName ->
Text -> Text -> ConcurrencyPolicyUpdate -> m Int64
forall (m :: * -> *).
MonadArbiter m =>
Text -> Text -> ConcurrencyPolicyUpdate -> m Int64
Ops.updateConcurrencyPolicyOverrides Text
schemaName Text
prefix ConcurrencyPolicyUpdate
upd
setConcurrencyLimit :: (MonadArbiter m) => ConcurrencyPolicy -> m Int64
setConcurrencyLimit :: forall (m :: * -> *).
MonadArbiter m =>
ConcurrencyPolicy -> m Int64
setConcurrencyLimit ConcurrencyPolicy
policy =
Text -> ConcurrencyPolicyUpdate -> m Int64
forall (m :: * -> *).
MonadArbiter m =>
Text -> ConcurrencyPolicyUpdate -> m Int64
updateConcurrencyPolicyOverrides
(ConcurrencyPolicy -> Text
forall p. AdmissionPolicy p => p -> Text
policyPrefixOf ConcurrencyPolicy
policy)
ConcurrencyPolicyUpdate {overrideLimit :: Maybe (Maybe Int32)
overrideLimit = Maybe Int32 -> Maybe (Maybe Int32)
forall a. a -> Maybe a
Just (Int32 -> Maybe Int32
forall a. a -> Maybe a
Just (ConcurrencyPolicy -> Int32
cpLimit ConcurrencyPolicy
policy))}
clearConcurrencyLimit :: (MonadArbiter m) => ConcurrencyPolicy -> m Int64
clearConcurrencyLimit :: forall (m :: * -> *).
MonadArbiter m =>
ConcurrencyPolicy -> m Int64
clearConcurrencyLimit ConcurrencyPolicy
policy =
Text -> ConcurrencyPolicyUpdate -> m Int64
forall (m :: * -> *).
MonadArbiter m =>
Text -> ConcurrencyPolicyUpdate -> m Int64
updateConcurrencyPolicyOverrides (ConcurrencyPolicy -> Text
forall p. AdmissionPolicy p => p -> Text
policyPrefixOf ConcurrencyPolicy
policy) ConcurrencyPolicyUpdate {overrideLimit :: Maybe (Maybe Int32)
overrideLimit = Maybe Int32 -> Maybe (Maybe Int32)
forall a. a -> Maybe a
Just Maybe Int32
forall a. Maybe a
Nothing}
pruneConcurrencyKeys
:: forall m
. (MonadArbiter m, RegistryTables (RegistryOf m))
=> m Int64
pruneConcurrencyKeys :: forall (m :: * -> *).
(MonadArbiter m, RegistryTables (RegistryOf m)) =>
m Int64
pruneConcurrencyKeys = (Text -> [Text] -> m Int64) -> m Int64
forall (m :: * -> *) a.
(MonadArbiter m, RegistryTables (RegistryOf m)) =>
(Text -> [Text] -> m a) -> m a
onRegistry Text -> [Text] -> m Int64
forall (m :: * -> *). MonadArbiter m => Text -> [Text] -> m Int64
Ops.pruneConcurrencyKeys
reconcileConcurrencyCounts
:: forall m
. (MonadArbiter m, RegistryTables (RegistryOf m))
=> m Int64
reconcileConcurrencyCounts :: forall (m :: * -> *).
(MonadArbiter m, RegistryTables (RegistryOf m)) =>
m Int64
reconcileConcurrencyCounts = (Text -> [Text] -> m Int64) -> m Int64
forall (m :: * -> *) a.
(MonadArbiter m, RegistryTables (RegistryOf m)) =>
(Text -> [Text] -> m a) -> m a
onRegistry Text -> [Text] -> m Int64
forall (m :: * -> *). MonadArbiter m => Text -> [Text] -> m Int64
Ops.reconcileConcurrencyCounts
reconcileConcurrencyCountsIfStale
:: forall m
. (MonadArbiter m, RegistryTables (RegistryOf m))
=> m Int64
reconcileConcurrencyCountsIfStale :: forall (m :: * -> *).
(MonadArbiter m, RegistryTables (RegistryOf m)) =>
m Int64
reconcileConcurrencyCountsIfStale = (Text -> [Text] -> m Int64) -> m Int64
forall (m :: * -> *) a.
(MonadArbiter m, RegistryTables (RegistryOf m)) =>
(Text -> [Text] -> m a) -> m a
onRegistry Text -> [Text] -> m Int64
forall (m :: * -> *). MonadArbiter m => Text -> [Text] -> m Int64
Ops.reconcileConcurrencyCountsIfStale
reconcileAndPruneConcurrency
:: forall m
. (MonadArbiter m, RegistryTables (RegistryOf m))
=> m Int64
reconcileAndPruneConcurrency :: forall (m :: * -> *).
(MonadArbiter m, RegistryTables (RegistryOf m)) =>
m Int64
reconcileAndPruneConcurrency = (Text -> [Text] -> m Int64) -> m Int64
forall (m :: * -> *) a.
(MonadArbiter m, RegistryTables (RegistryOf m)) =>
(Text -> [Text] -> m a) -> m a
onRegistry Text -> [Text] -> m Int64
forall (m :: * -> *). MonadArbiter m => Text -> [Text] -> m Int64
Ops.reconcileAndPruneConcurrency
listJobsFiltered
:: forall payload m
. (QueueOperation m payload)
=> [Ops.JobFilter]
-> Int
-> Int
-> m [JobRead payload]
listJobsFiltered :: forall payload (m :: * -> *).
QueueOperation m payload =>
[JobFilter] -> Int -> Int -> m [JobRead payload]
listJobsFiltered [JobFilter]
filters Int
limit Int
offset =
forall payload (m :: * -> *) a.
(KnownSymbol (TableForPayload payload (RegistryOf m)),
MonadArbiter m) =>
(Text -> Text -> m a) -> m a
onQueue @payload ((Text -> Text -> m [JobRead payload]) -> m [JobRead payload])
-> (Text -> Text -> m [JobRead payload]) -> m [JobRead payload]
forall a b. (a -> b) -> a -> b
$ \Text
schemaName Text
tableName ->
Text
-> Text
-> [JobFilter]
-> Int
-> Int
-> m [JobRead (Stored payload)]
forall (m :: * -> *) payload.
MonadArbiter m =>
Text
-> Text
-> [JobFilter]
-> Int
-> Int
-> m [JobRead (Stored payload)]
Ops.listJobsFiltered Text
schemaName Text
tableName [JobFilter]
filters Int
limit Int
offset m [JobRead (Stored payload)]
-> ([JobRead (Stored payload)] -> m [JobRead payload])
-> m [JobRead payload]
forall a b. m a -> (a -> m b) -> m b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (JobRead (Stored payload) -> m (JobRead payload))
-> [JobRead (Stored payload)] -> m [JobRead payload]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> [a] -> f [b]
traverse JobRead (Stored payload) -> m (JobRead payload)
forall payload (m :: * -> *).
(FromJSON payload, MonadArbiter m) =>
JobRead (Stored payload) -> m (JobRead payload)
Ops.typedRow
countJobsFiltered
:: forall payload m
. (QueueOperation m payload)
=> [Ops.JobFilter]
-> m Int64
countJobsFiltered :: forall payload (m :: * -> *).
QueueOperation m payload =>
[JobFilter] -> m Int64
countJobsFiltered [JobFilter]
filters =
forall payload (m :: * -> *) a.
(KnownSymbol (TableForPayload payload (RegistryOf m)),
MonadArbiter m) =>
(Text -> Text -> m a) -> m a
onQueue @payload ((Text -> Text -> m Int64) -> m Int64)
-> (Text -> Text -> m Int64) -> m Int64
forall a b. (a -> b) -> a -> b
$ \Text
schemaName Text
tableName ->
Text -> Text -> [JobFilter] -> m Int64
forall (m :: * -> *).
MonadArbiter m =>
Text -> Text -> [JobFilter] -> m Int64
Ops.countJobsFiltered Text
schemaName Text
tableName [JobFilter]
filters
listDLQFiltered
:: forall payload m
. (QueueOperation m payload)
=> [Ops.JobFilter]
-> Int
-> Int
-> m [DLQ.DLQJob payload]
listDLQFiltered :: forall payload (m :: * -> *).
QueueOperation m payload =>
[JobFilter] -> Int -> Int -> m [DLQJob payload]
listDLQFiltered [JobFilter]
filters Int
limit Int
offset =
forall payload (m :: * -> *) a.
(KnownSymbol (TableForPayload payload (RegistryOf m)),
MonadArbiter m) =>
(Text -> Text -> m a) -> m a
onQueue @payload ((Text -> Text -> m [DLQJob payload]) -> m [DLQJob payload])
-> (Text -> Text -> m [DLQJob payload]) -> m [DLQJob payload]
forall a b. (a -> b) -> a -> b
$ \Text
schemaName Text
tableName ->
Text
-> Text -> [JobFilter] -> Int -> Int -> m [DLQJob (Stored payload)]
forall (m :: * -> *) payload.
MonadArbiter m =>
Text
-> Text -> [JobFilter] -> Int -> Int -> m [DLQJob (Stored payload)]
Ops.listDLQFiltered Text
schemaName Text
tableName [JobFilter]
filters Int
limit Int
offset m [DLQJob (Stored payload)]
-> ([DLQJob (Stored payload)] -> m [DLQJob payload])
-> m [DLQJob payload]
forall a b. m a -> (a -> m b) -> m b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (DLQJob (Stored payload) -> m (DLQJob payload))
-> [DLQJob (Stored payload)] -> m [DLQJob payload]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> [a] -> f [b]
traverse DLQJob (Stored payload) -> m (DLQJob payload)
forall payload (m :: * -> *).
(FromJSON payload, MonadArbiter m) =>
DLQJob (Stored payload) -> m (DLQJob payload)
Ops.typedDLQRow
countDLQFiltered
:: forall payload m
. (QueueOperation m payload)
=> [Ops.JobFilter]
-> m Int64
countDLQFiltered :: forall payload (m :: * -> *).
QueueOperation m payload =>
[JobFilter] -> m Int64
countDLQFiltered [JobFilter]
filters = forall payload (m :: * -> *) a.
(KnownSymbol (TableForPayload payload (RegistryOf m)),
MonadArbiter m) =>
(Text -> Text -> m a) -> m a
onQueue @payload ((Text -> Text -> m Int64) -> m Int64)
-> (Text -> Text -> m Int64) -> m Int64
forall a b. (a -> b) -> a -> b
$ \Text
schemaName Text
tableName -> Text -> Text -> [JobFilter] -> m Int64
forall (m :: * -> *).
MonadArbiter m =>
Text -> Text -> [JobFilter] -> m Int64
Ops.countDLQFiltered Text
schemaName Text
tableName [JobFilter]
filters
listArchiveFiltered
:: forall payload m
. (QueueOperation m payload)
=> [Ops.JobFilter]
-> Int
-> Int
-> m [Archive.ArchiveJob payload]
listArchiveFiltered :: forall payload (m :: * -> *).
QueueOperation m payload =>
[JobFilter] -> Int -> Int -> m [ArchiveJob payload]
listArchiveFiltered [JobFilter]
filters Int
limit Int
offset = forall payload (m :: * -> *) a.
(KnownSymbol (TableForPayload payload (RegistryOf m)),
MonadArbiter m) =>
(Text -> Text -> m a) -> m a
onQueue @payload ((Text -> Text -> m [ArchiveJob payload])
-> m [ArchiveJob payload])
-> (Text -> Text -> m [ArchiveJob payload])
-> m [ArchiveJob payload]
forall a b. (a -> b) -> a -> b
$ \Text
schemaName Text
tableName ->
Text
-> Text
-> [JobFilter]
-> Maybe ArchiveSortColumn
-> Maybe SortDir
-> Int
-> Int
-> m [ArchiveJob (Stored payload)]
forall (m :: * -> *) payload.
MonadArbiter m =>
Text
-> Text
-> [JobFilter]
-> Maybe ArchiveSortColumn
-> Maybe SortDir
-> Int
-> Int
-> m [ArchiveJob (Stored payload)]
Ops.listArchiveFiltered Text
schemaName Text
tableName [JobFilter]
filters Maybe ArchiveSortColumn
forall a. Maybe a
Nothing Maybe SortDir
forall a. Maybe a
Nothing Int
limit Int
offset m [ArchiveJob (Stored payload)]
-> ([ArchiveJob (Stored payload)] -> m [ArchiveJob payload])
-> m [ArchiveJob payload]
forall a b. m a -> (a -> m b) -> m b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (ArchiveJob (Stored payload) -> m (ArchiveJob payload))
-> [ArchiveJob (Stored payload)] -> m [ArchiveJob payload]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> [a] -> f [b]
traverse ArchiveJob (Stored payload) -> m (ArchiveJob payload)
forall payload (m :: * -> *).
(FromJSON payload, MonadArbiter m) =>
ArchiveJob (Stored payload) -> m (ArchiveJob payload)
Ops.typedArchiveRow
countArchiveFiltered
:: forall payload m
. (QueueOperation m payload)
=> [Ops.JobFilter]
-> m Int64
countArchiveFiltered :: forall payload (m :: * -> *).
QueueOperation m payload =>
[JobFilter] -> m Int64
countArchiveFiltered [JobFilter]
filters =
forall payload (m :: * -> *) a.
(KnownSymbol (TableForPayload payload (RegistryOf m)),
MonadArbiter m) =>
(Text -> Text -> m a) -> m a
onQueue @payload ((Text -> Text -> m Int64) -> m Int64)
-> (Text -> Text -> m Int64) -> m Int64
forall a b. (a -> b) -> a -> b
$ \Text
schemaName Text
tableName ->
Text -> Text -> [JobFilter] -> m Int64
forall (m :: * -> *).
MonadArbiter m =>
Text -> Text -> [JobFilter] -> m Int64
Ops.countArchiveFiltered Text
schemaName Text
tableName [JobFilter]
filters
moveToDLQ
:: forall payload m
. (MonadArbiter m)
=> Text
-> JobRead payload
-> m Int64
moveToDLQ :: forall payload (m :: * -> *).
MonadArbiter m =>
Text -> JobRead payload -> m Int64
moveToDLQ Text
errorMsg JobRead payload
job =
JobRead payload -> (Text -> Text -> m Int64) -> m Int64
forall (m :: * -> *) payload a.
MonadArbiter m =>
JobRead payload -> (Text -> Text -> m a) -> m a
onJob JobRead payload
job ((Text -> Text -> m Int64) -> m Int64)
-> (Text -> Text -> m Int64) -> m Int64
forall a b. (a -> b) -> a -> b
$ \Text
schemaName Text
tableName ->
TreeLocks -> Text -> Text -> Text -> JobRead payload -> m Int64
forall (m :: * -> *) payload.
MonadArbiter m =>
TreeLocks -> Text -> Text -> Text -> JobRead payload -> m Int64
Ops.moveToDLQ TreeLocks
Ops.TakeLocks Text
schemaName Text
tableName Text
errorMsg JobRead payload
job
moveToDLQBatch
:: forall payload m
. (MonadArbiter m)
=> [(JobRead payload, Text)]
-> m Int64
moveToDLQBatch :: forall payload (m :: * -> *).
MonadArbiter m =>
[(JobRead payload, Text)] -> m Int64
moveToDLQBatch [(JobRead payload, Text)]
jobsWithErrors =
((JobRead payload, Text) -> JobRead payload)
-> Int64
-> [(JobRead payload, Text)]
-> (Text -> Text -> m Int64)
-> m Int64
forall (m :: * -> *) item payload a.
MonadArbiter m =>
(item -> JobRead payload)
-> a -> [item] -> (Text -> Text -> m a) -> m a
onJobs (JobRead payload, Text) -> JobRead payload
forall a b. (a, b) -> a
fst Int64
0 [(JobRead payload, Text)]
jobsWithErrors ((Text -> Text -> m Int64) -> m Int64)
-> (Text -> Text -> m Int64) -> m Int64
forall a b. (a -> b) -> a -> b
$ \Text
schemaName Text
tableName -> Text -> Text -> [(JobRead payload, Text)] -> m Int64
forall (m :: * -> *) payload.
MonadArbiter m =>
Text -> Text -> [(JobRead payload, Text)] -> m Int64
Ops.moveToDLQBatch Text
schemaName Text
tableName [(JobRead payload, Text)]
jobsWithErrors
listDLQJobs
:: forall payload m
. (QueueOperation m payload)
=> Int
-> Int
-> m [DLQ.DLQJob payload]
listDLQJobs :: forall payload (m :: * -> *).
QueueOperation m payload =>
Int -> Int -> m [DLQJob payload]
listDLQJobs Int
limit Int
offset =
forall payload (m :: * -> *) a.
(KnownSymbol (TableForPayload payload (RegistryOf m)),
MonadArbiter m) =>
(Text -> Text -> m a) -> m a
onQueue @payload ((Text -> Text -> m [DLQJob payload]) -> m [DLQJob payload])
-> (Text -> Text -> m [DLQJob payload]) -> m [DLQJob payload]
forall a b. (a -> b) -> a -> b
$ \Text
schemaName Text
tableName ->
Text -> Text -> Int -> Int -> m [DLQJob (Stored payload)]
forall (m :: * -> *) payload.
MonadArbiter m =>
Text -> Text -> Int -> Int -> m [DLQJob (Stored payload)]
Ops.listDLQJobs Text
schemaName Text
tableName Int
limit Int
offset m [DLQJob (Stored payload)]
-> ([DLQJob (Stored payload)] -> m [DLQJob payload])
-> m [DLQJob payload]
forall a b. m a -> (a -> m b) -> m b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (DLQJob (Stored payload) -> m (DLQJob payload))
-> [DLQJob (Stored payload)] -> m [DLQJob payload]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> [a] -> f [b]
traverse DLQJob (Stored payload) -> m (DLQJob payload)
forall payload (m :: * -> *).
(FromJSON payload, MonadArbiter m) =>
DLQJob (Stored payload) -> m (DLQJob payload)
Ops.typedDLQRow
retryFromDLQ
:: forall payload m
. (QueueOperation m payload)
=> Int64
-> m (Maybe (JobRead payload))
retryFromDLQ :: forall payload (m :: * -> *).
QueueOperation m payload =>
Int64 -> m (Maybe (JobRead payload))
retryFromDLQ Int64
dlqId = forall payload (m :: * -> *) a.
(KnownSymbol (TableForPayload payload (RegistryOf m)),
MonadArbiter m) =>
(Text -> Text -> m a) -> m a
onQueue @payload ((Text -> Text -> m (Maybe (JobRead payload)))
-> m (Maybe (JobRead payload)))
-> (Text -> Text -> m (Maybe (JobRead payload)))
-> m (Maybe (JobRead payload))
forall a b. (a -> b) -> a -> b
$ \Text
schemaName Text
tableName ->
m (Maybe (JobRead payload)) -> m (Maybe (JobRead payload))
forall a. m a -> m a
forall (m :: * -> *) a. MonadArbiter m => m a -> m a
withDbTransaction (Text -> Text -> Int64 -> m (Maybe (JobRead (Stored payload)))
forall (m :: * -> *) payload.
MonadArbiter m =>
Text -> Text -> Int64 -> m (Maybe (JobRead (Stored payload)))
Ops.retryFromDLQ Text
schemaName Text
tableName Int64
dlqId m (Maybe (JobRead (Stored payload)))
-> (Maybe (JobRead (Stored payload))
-> m (Maybe (JobRead payload)))
-> m (Maybe (JobRead payload))
forall a b. m a -> (a -> m b) -> m b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (JobRead (Stored payload) -> m (JobRead payload))
-> Maybe (JobRead (Stored payload)) -> m (Maybe (JobRead payload))
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Maybe a -> f (Maybe b)
traverse JobRead (Stored payload) -> m (JobRead payload)
forall payload (m :: * -> *).
(FromJSON payload, MonadArbiter m) =>
JobRead (Stored payload) -> m (JobRead payload)
Ops.typedRow)
retryFromDLQWithPayload
:: forall payload m
. (QueueOperation m payload)
=> Int64
-> payload
-> m (Maybe (JobRead payload))
retryFromDLQWithPayload :: forall payload (m :: * -> *).
QueueOperation m payload =>
Int64 -> payload -> m (Maybe (JobRead payload))
retryFromDLQWithPayload Int64
dlqId payload
replacement = forall payload (m :: * -> *) a.
(KnownSymbol (TableForPayload payload (RegistryOf m)),
MonadArbiter m) =>
(Text -> Text -> m a) -> m a
onQueue @payload ((Text -> Text -> m (Maybe (JobRead payload)))
-> m (Maybe (JobRead payload)))
-> (Text -> Text -> m (Maybe (JobRead payload)))
-> m (Maybe (JobRead payload))
forall a b. (a -> b) -> a -> b
$ \Text
schemaName Text
tableName ->
m (Maybe (JobRead payload)) -> m (Maybe (JobRead payload))
forall a. m a -> m a
forall (m :: * -> *) a. MonadArbiter m => m a -> m a
withDbTransaction
(Text
-> Text
-> Int64
-> Maybe payload
-> m (Maybe (JobRead (Stored payload)))
forall (m :: * -> *) payload.
(JobPayload payload, MonadArbiter m) =>
Text
-> Text
-> Int64
-> Maybe payload
-> m (Maybe (JobRead (Stored payload)))
Ops.retryFromDLQWithPayload Text
schemaName Text
tableName Int64
dlqId (payload -> Maybe payload
forall a. a -> Maybe a
Just payload
replacement) m (Maybe (JobRead (Stored payload)))
-> (Maybe (JobRead (Stored payload))
-> m (Maybe (JobRead payload)))
-> m (Maybe (JobRead payload))
forall a b. m a -> (a -> m b) -> m b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (JobRead (Stored payload) -> m (JobRead payload))
-> Maybe (JobRead (Stored payload)) -> m (Maybe (JobRead payload))
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Maybe a -> f (Maybe b)
traverse JobRead (Stored payload) -> m (JobRead payload)
forall payload (m :: * -> *).
(FromJSON payload, MonadArbiter m) =>
JobRead (Stored payload) -> m (JobRead payload)
Ops.typedRow)
retryFromDLQBatch
:: forall payload m
. (QueueOperation m payload)
=> [Int64]
-> m Int64
retryFromDLQBatch :: forall payload (m :: * -> *).
QueueOperation m payload =>
[Int64] -> m Int64
retryFromDLQBatch [Int64]
dlqIds = forall payload (m :: * -> *) a.
(KnownSymbol (TableForPayload payload (RegistryOf m)),
MonadArbiter m) =>
(Text -> Text -> m a) -> m a
onQueue @payload ((Text -> Text -> m Int64) -> m Int64)
-> (Text -> Text -> m Int64) -> m Int64
forall a b. (a -> b) -> a -> b
$ \Text
schemaName Text
tableName -> Text -> Text -> [Int64] -> m Int64
forall (m :: * -> *).
MonadArbiter m =>
Text -> Text -> [Int64] -> m Int64
Ops.retryFromDLQBatch Text
schemaName Text
tableName [Int64]
dlqIds
retryDLQFiltered
:: forall payload m
. (QueueOperation m payload)
=> [Ops.JobFilter]
-> m Int64
retryDLQFiltered :: forall payload (m :: * -> *).
QueueOperation m payload =>
[JobFilter] -> m Int64
retryDLQFiltered [JobFilter]
filters = forall payload (m :: * -> *) a.
(KnownSymbol (TableForPayload payload (RegistryOf m)),
MonadArbiter m) =>
(Text -> Text -> m a) -> m a
onQueue @payload ((Text -> Text -> m Int64) -> m Int64)
-> (Text -> Text -> m Int64) -> m Int64
forall a b. (a -> b) -> a -> b
$ \Text
schemaName Text
tableName -> Text -> Text -> [JobFilter] -> m Int64
forall (m :: * -> *).
MonadArbiter m =>
Text -> Text -> [JobFilter] -> m Int64
Ops.retryDLQFiltered Text
schemaName Text
tableName [JobFilter]
filters
dlqJobExists
:: forall payload m
. (QueueOperation m payload)
=> Int64
-> m Bool
dlqJobExists :: forall payload (m :: * -> *).
QueueOperation m payload =>
Int64 -> m Bool
dlqJobExists Int64
dlqId = forall payload (m :: * -> *) a.
(KnownSymbol (TableForPayload payload (RegistryOf m)),
MonadArbiter m) =>
(Text -> Text -> m a) -> m a
onQueue @payload ((Text -> Text -> m Bool) -> m Bool)
-> (Text -> Text -> m Bool) -> m Bool
forall a b. (a -> b) -> a -> b
$ \Text
schemaName Text
tableName -> Text -> Text -> Int64 -> m Bool
forall (m :: * -> *).
MonadArbiter m =>
Text -> Text -> Int64 -> m Bool
Ops.dlqJobExists Text
schemaName Text
tableName Int64
dlqId
deleteDLQJob
:: forall payload m
. (QueueOperation m payload)
=> Int64
-> m Int64
deleteDLQJob :: forall payload (m :: * -> *).
QueueOperation m payload =>
Int64 -> m Int64
deleteDLQJob Int64
dlqId = forall payload (m :: * -> *) a.
(KnownSymbol (TableForPayload payload (RegistryOf m)),
MonadArbiter m) =>
(Text -> Text -> m a) -> m a
onQueue @payload ((Text -> Text -> m Int64) -> m Int64)
-> (Text -> Text -> m Int64) -> m Int64
forall a b. (a -> b) -> a -> b
$ \Text
schemaName Text
tableName -> Text -> Text -> Int64 -> m Int64
forall (m :: * -> *).
MonadArbiter m =>
Text -> Text -> Int64 -> m Int64
Ops.deleteDLQJob Text
schemaName Text
tableName Int64
dlqId
deleteDLQJobsBatch
:: forall payload m
. (QueueOperation m payload)
=> [Int64]
-> m Int64
deleteDLQJobsBatch :: forall payload (m :: * -> *).
QueueOperation m payload =>
[Int64] -> m Int64
deleteDLQJobsBatch [Int64]
dlqIds =
forall payload (m :: * -> *) a.
(KnownSymbol (TableForPayload payload (RegistryOf m)),
MonadArbiter m) =>
(Text -> Text -> m a) -> m a
onQueue @payload ((Text -> Text -> m Int64) -> m Int64)
-> (Text -> Text -> m Int64) -> m Int64
forall a b. (a -> b) -> a -> b
$ \Text
schemaName Text
tableName ->
Text -> Text -> [Int64] -> m Int64
forall (m :: * -> *).
MonadArbiter m =>
Text -> Text -> [Int64] -> m Int64
Ops.deleteDLQJobsBatch Text
schemaName Text
tableName [Int64]
dlqIds
listArchiveJobs
:: forall payload m
. (QueueOperation m payload)
=> Int
-> Int
-> m [Archive.ArchiveJob payload]
listArchiveJobs :: forall payload (m :: * -> *).
QueueOperation m payload =>
Int -> Int -> m [ArchiveJob payload]
listArchiveJobs Int
limit Int
offset =
forall payload (m :: * -> *) a.
(KnownSymbol (TableForPayload payload (RegistryOf m)),
MonadArbiter m) =>
(Text -> Text -> m a) -> m a
onQueue @payload ((Text -> Text -> m [ArchiveJob payload])
-> m [ArchiveJob payload])
-> (Text -> Text -> m [ArchiveJob payload])
-> m [ArchiveJob payload]
forall a b. (a -> b) -> a -> b
$ \Text
schemaName Text
tableName ->
Text -> Text -> Int -> Int -> m [ArchiveJob (Stored payload)]
forall (m :: * -> *) payload.
MonadArbiter m =>
Text -> Text -> Int -> Int -> m [ArchiveJob (Stored payload)]
Ops.listArchiveJobs Text
schemaName Text
tableName Int
limit Int
offset m [ArchiveJob (Stored payload)]
-> ([ArchiveJob (Stored payload)] -> m [ArchiveJob payload])
-> m [ArchiveJob payload]
forall a b. m a -> (a -> m b) -> m b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (ArchiveJob (Stored payload) -> m (ArchiveJob payload))
-> [ArchiveJob (Stored payload)] -> m [ArchiveJob payload]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> [a] -> f [b]
traverse ArchiveJob (Stored payload) -> m (ArchiveJob payload)
forall payload (m :: * -> *).
(FromJSON payload, MonadArbiter m) =>
ArchiveJob (Stored payload) -> m (ArchiveJob payload)
Ops.typedArchiveRow
getArchiveJobById
:: forall payload m
. (QueueOperation m payload)
=> Int64
-> m (Maybe (Archive.ArchiveJob payload))
getArchiveJobById :: forall payload (m :: * -> *).
QueueOperation m payload =>
Int64 -> m (Maybe (ArchiveJob payload))
getArchiveJobById Int64
jobId =
forall payload (m :: * -> *) a.
(KnownSymbol (TableForPayload payload (RegistryOf m)),
MonadArbiter m) =>
(Text -> Text -> m a) -> m a
onQueue @payload ((Text -> Text -> m (Maybe (ArchiveJob payload)))
-> m (Maybe (ArchiveJob payload)))
-> (Text -> Text -> m (Maybe (ArchiveJob payload)))
-> m (Maybe (ArchiveJob payload))
forall a b. (a -> b) -> a -> b
$ \Text
schemaName Text
tableName ->
Text -> Text -> Int64 -> m (Maybe (ArchiveJob (Stored payload)))
forall (m :: * -> *) payload.
MonadArbiter m =>
Text -> Text -> Int64 -> m (Maybe (ArchiveJob (Stored payload)))
Ops.getArchiveJobById Text
schemaName Text
tableName Int64
jobId m (Maybe (ArchiveJob (Stored payload)))
-> (Maybe (ArchiveJob (Stored payload))
-> m (Maybe (ArchiveJob payload)))
-> m (Maybe (ArchiveJob payload))
forall a b. m a -> (a -> m b) -> m b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (ArchiveJob (Stored payload) -> m (ArchiveJob payload))
-> Maybe (ArchiveJob (Stored payload))
-> m (Maybe (ArchiveJob payload))
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Maybe a -> f (Maybe b)
traverse ArchiveJob (Stored payload) -> m (ArchiveJob payload)
forall payload (m :: * -> *).
(FromJSON payload, MonadArbiter m) =>
ArchiveJob (Stored payload) -> m (ArchiveJob payload)
Ops.typedArchiveRow
listArchiveJobsByGroup
:: forall payload m
. (QueueOperation m payload)
=> Text
-> Int
-> Int
-> m [Archive.ArchiveJob payload]
listArchiveJobsByGroup :: forall payload (m :: * -> *).
QueueOperation m payload =>
Text -> Int -> Int -> m [ArchiveJob payload]
listArchiveJobsByGroup Text
groupKey Int
limit Int
offset =
forall payload (m :: * -> *) a.
(KnownSymbol (TableForPayload payload (RegistryOf m)),
MonadArbiter m) =>
(Text -> Text -> m a) -> m a
onQueue @payload ((Text -> Text -> m [ArchiveJob payload])
-> m [ArchiveJob payload])
-> (Text -> Text -> m [ArchiveJob payload])
-> m [ArchiveJob payload]
forall a b. (a -> b) -> a -> b
$ \Text
schemaName Text
tableName ->
Text
-> Text -> Text -> Int -> Int -> m [ArchiveJob (Stored payload)]
forall (m :: * -> *) payload.
MonadArbiter m =>
Text
-> Text -> Text -> Int -> Int -> m [ArchiveJob (Stored payload)]
Ops.listArchiveJobsByGroup Text
schemaName Text
tableName Text
groupKey Int
limit Int
offset m [ArchiveJob (Stored payload)]
-> ([ArchiveJob (Stored payload)] -> m [ArchiveJob payload])
-> m [ArchiveJob payload]
forall a b. m a -> (a -> m b) -> m b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (ArchiveJob (Stored payload) -> m (ArchiveJob payload))
-> [ArchiveJob (Stored payload)] -> m [ArchiveJob payload]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> [a] -> f [b]
traverse ArchiveJob (Stored payload) -> m (ArchiveJob payload)
forall payload (m :: * -> *).
(FromJSON payload, MonadArbiter m) =>
ArchiveJob (Stored payload) -> m (ArchiveJob payload)
Ops.typedArchiveRow
deleteArchiveJob
:: forall payload m
. (QueueOperation m payload)
=> Int64
-> m Int64
deleteArchiveJob :: forall payload (m :: * -> *).
QueueOperation m payload =>
Int64 -> m Int64
deleteArchiveJob Int64
archiveId =
forall payload (m :: * -> *) a.
(KnownSymbol (TableForPayload payload (RegistryOf m)),
MonadArbiter m) =>
(Text -> Text -> m a) -> m a
onQueue @payload ((Text -> Text -> m Int64) -> m Int64)
-> (Text -> Text -> m Int64) -> m Int64
forall a b. (a -> b) -> a -> b
$ \Text
schemaName Text
tableName ->
Text -> Text -> Int64 -> m Int64
forall (m :: * -> *).
MonadArbiter m =>
Text -> Text -> Int64 -> m Int64
Ops.deleteArchiveJob Text
schemaName Text
tableName Int64
archiveId
deleteArchiveJobsBatch
:: forall payload m
. (QueueOperation m payload)
=> [Int64]
-> m Int64
deleteArchiveJobsBatch :: forall payload (m :: * -> *).
QueueOperation m payload =>
[Int64] -> m Int64
deleteArchiveJobsBatch [Int64]
archiveIds =
forall payload (m :: * -> *) a.
(KnownSymbol (TableForPayload payload (RegistryOf m)),
MonadArbiter m) =>
(Text -> Text -> m a) -> m a
onQueue @payload ((Text -> Text -> m Int64) -> m Int64)
-> (Text -> Text -> m Int64) -> m Int64
forall a b. (a -> b) -> a -> b
$ \Text
schemaName Text
tableName ->
Text -> Text -> [Int64] -> m Int64
forall (m :: * -> *).
MonadArbiter m =>
Text -> Text -> [Int64] -> m Int64
Ops.deleteArchiveJobsBatch Text
schemaName Text
tableName [Int64]
archiveIds
reEnqueueFromArchive
:: forall payload m
. (QueueOperation m payload)
=> Int64
-> m (Maybe (JobRead payload))
reEnqueueFromArchive :: forall payload (m :: * -> *).
QueueOperation m payload =>
Int64 -> m (Maybe (JobRead payload))
reEnqueueFromArchive Int64
archiveId = forall payload (m :: * -> *) a.
(KnownSymbol (TableForPayload payload (RegistryOf m)),
MonadArbiter m) =>
(Text -> Text -> m a) -> m a
onQueue @payload ((Text -> Text -> m (Maybe (JobRead payload)))
-> m (Maybe (JobRead payload)))
-> (Text -> Text -> m (Maybe (JobRead payload)))
-> m (Maybe (JobRead payload))
forall a b. (a -> b) -> a -> b
$ \Text
schemaName Text
tableName ->
m (Maybe (JobRead payload)) -> m (Maybe (JobRead payload))
forall a. m a -> m a
forall (m :: * -> *) a. MonadArbiter m => m a -> m a
withDbTransaction (Text -> Text -> Int64 -> m (Maybe (JobRead (Stored payload)))
forall (m :: * -> *) payload.
MonadArbiter m =>
Text -> Text -> Int64 -> m (Maybe (JobRead (Stored payload)))
Ops.reEnqueueFromArchive Text
schemaName Text
tableName Int64
archiveId m (Maybe (JobRead (Stored payload)))
-> (Maybe (JobRead (Stored payload))
-> m (Maybe (JobRead payload)))
-> m (Maybe (JobRead payload))
forall a b. m a -> (a -> m b) -> m b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (JobRead (Stored payload) -> m (JobRead payload))
-> Maybe (JobRead (Stored payload)) -> m (Maybe (JobRead payload))
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Maybe a -> f (Maybe b)
traverse JobRead (Stored payload) -> m (JobRead payload)
forall payload (m :: * -> *).
(FromJSON payload, MonadArbiter m) =>
JobRead (Stored payload) -> m (JobRead payload)
Ops.typedRow)
reEnqueueFromArchiveWithPayload
:: forall payload m
. (QueueOperation m payload)
=> Int64
-> payload
-> m (Maybe (JobRead payload))
reEnqueueFromArchiveWithPayload :: forall payload (m :: * -> *).
QueueOperation m payload =>
Int64 -> payload -> m (Maybe (JobRead payload))
reEnqueueFromArchiveWithPayload Int64
archiveId payload
replacement = forall payload (m :: * -> *) a.
(KnownSymbol (TableForPayload payload (RegistryOf m)),
MonadArbiter m) =>
(Text -> Text -> m a) -> m a
onQueue @payload ((Text -> Text -> m (Maybe (JobRead payload)))
-> m (Maybe (JobRead payload)))
-> (Text -> Text -> m (Maybe (JobRead payload)))
-> m (Maybe (JobRead payload))
forall a b. (a -> b) -> a -> b
$ \Text
schemaName Text
tableName ->
m (Maybe (JobRead payload)) -> m (Maybe (JobRead payload))
forall a. m a -> m a
forall (m :: * -> *) a. MonadArbiter m => m a -> m a
withDbTransaction
(Text
-> Text
-> Int64
-> Maybe payload
-> m (Maybe (JobRead (Stored payload)))
forall (m :: * -> *) payload.
(JobPayload payload, MonadArbiter m) =>
Text
-> Text
-> Int64
-> Maybe payload
-> m (Maybe (JobRead (Stored payload)))
Ops.reEnqueueFromArchiveWithPayload Text
schemaName Text
tableName Int64
archiveId (payload -> Maybe payload
forall a. a -> Maybe a
Just payload
replacement) m (Maybe (JobRead (Stored payload)))
-> (Maybe (JobRead (Stored payload))
-> m (Maybe (JobRead payload)))
-> m (Maybe (JobRead payload))
forall a b. m a -> (a -> m b) -> m b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (JobRead (Stored payload) -> m (JobRead payload))
-> Maybe (JobRead (Stored payload)) -> m (Maybe (JobRead payload))
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Maybe a -> f (Maybe b)
traverse JobRead (Stored payload) -> m (JobRead payload)
forall payload (m :: * -> *).
(FromJSON payload, MonadArbiter m) =>
JobRead (Stored payload) -> m (JobRead payload)
Ops.typedRow)
listJobs
:: forall payload m
. (QueueOperation m payload)
=> Int
-> Int
-> m [JobRead payload]
listJobs :: forall payload (m :: * -> *).
QueueOperation m payload =>
Int -> Int -> m [JobRead payload]
listJobs Int
limit Int
offset =
forall payload (m :: * -> *) a.
(KnownSymbol (TableForPayload payload (RegistryOf m)),
MonadArbiter m) =>
(Text -> Text -> m a) -> m a
onQueue @payload ((Text -> Text -> m [JobRead payload]) -> m [JobRead payload])
-> (Text -> Text -> m [JobRead payload]) -> m [JobRead payload]
forall a b. (a -> b) -> a -> b
$ \Text
schemaName Text
tableName ->
Text -> Text -> Int -> Int -> m [JobRead (Stored payload)]
forall (m :: * -> *) payload.
MonadArbiter m =>
Text -> Text -> Int -> Int -> m [JobRead (Stored payload)]
Ops.listJobs Text
schemaName Text
tableName Int
limit Int
offset m [JobRead (Stored payload)]
-> ([JobRead (Stored payload)] -> m [JobRead payload])
-> m [JobRead payload]
forall a b. m a -> (a -> m b) -> m b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (JobRead (Stored payload) -> m (JobRead payload))
-> [JobRead (Stored payload)] -> m [JobRead payload]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> [a] -> f [b]
traverse JobRead (Stored payload) -> m (JobRead payload)
forall payload (m :: * -> *).
(FromJSON payload, MonadArbiter m) =>
JobRead (Stored payload) -> m (JobRead payload)
Ops.typedRow
getJobById
:: forall payload m
. (QueueOperation m payload)
=> Int64
-> m (Maybe (JobRead payload))
getJobById :: forall payload (m :: * -> *).
QueueOperation m payload =>
Int64 -> m (Maybe (JobRead payload))
getJobById Int64
jobId =
forall payload (m :: * -> *) a.
(KnownSymbol (TableForPayload payload (RegistryOf m)),
MonadArbiter m) =>
(Text -> Text -> m a) -> m a
onQueue @payload ((Text -> Text -> m (Maybe (JobRead payload)))
-> m (Maybe (JobRead payload)))
-> (Text -> Text -> m (Maybe (JobRead payload)))
-> m (Maybe (JobRead payload))
forall a b. (a -> b) -> a -> b
$ \Text
schemaName Text
tableName ->
Text -> Text -> Int64 -> m (Maybe (JobRead (Stored payload)))
forall (m :: * -> *) payload.
MonadArbiter m =>
Text -> Text -> Int64 -> m (Maybe (JobRead (Stored payload)))
Ops.getJobById Text
schemaName Text
tableName Int64
jobId m (Maybe (JobRead (Stored payload)))
-> (Maybe (JobRead (Stored payload))
-> m (Maybe (JobRead payload)))
-> m (Maybe (JobRead payload))
forall a b. m a -> (a -> m b) -> m b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (JobRead (Stored payload) -> m (JobRead payload))
-> Maybe (JobRead (Stored payload)) -> m (Maybe (JobRead payload))
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Maybe a -> f (Maybe b)
traverse JobRead (Stored payload) -> m (JobRead payload)
forall payload (m :: * -> *).
(FromJSON payload, MonadArbiter m) =>
JobRead (Stored payload) -> m (JobRead payload)
Ops.typedRow
jobExists
:: forall payload m
. (QueueOperation m payload)
=> Int64
-> m Bool
jobExists :: forall payload (m :: * -> *).
QueueOperation m payload =>
Int64 -> m Bool
jobExists Int64
jobId = forall payload (m :: * -> *) a.
(KnownSymbol (TableForPayload payload (RegistryOf m)),
MonadArbiter m) =>
(Text -> Text -> m a) -> m a
onQueue @payload ((Text -> Text -> m Bool) -> m Bool)
-> (Text -> Text -> m Bool) -> m Bool
forall a b. (a -> b) -> a -> b
$ \Text
schemaName Text
tableName -> Text -> Text -> Int64 -> m Bool
forall (m :: * -> *).
MonadArbiter m =>
Text -> Text -> Int64 -> m Bool
Ops.jobExists Text
schemaName Text
tableName Int64
jobId
listJobsByGroup
:: forall payload m
. (QueueOperation m payload)
=> Text
-> Int
-> Int
-> m [JobRead payload]
listJobsByGroup :: forall payload (m :: * -> *).
QueueOperation m payload =>
Text -> Int -> Int -> m [JobRead payload]
listJobsByGroup Text
groupKey Int
limit Int
offset =
forall payload (m :: * -> *) a.
(KnownSymbol (TableForPayload payload (RegistryOf m)),
MonadArbiter m) =>
(Text -> Text -> m a) -> m a
onQueue @payload ((Text -> Text -> m [JobRead payload]) -> m [JobRead payload])
-> (Text -> Text -> m [JobRead payload]) -> m [JobRead payload]
forall a b. (a -> b) -> a -> b
$ \Text
schemaName Text
tableName ->
Text -> Text -> Text -> Int -> Int -> m [JobRead (Stored payload)]
forall (m :: * -> *) payload.
MonadArbiter m =>
Text -> Text -> Text -> Int -> Int -> m [JobRead (Stored payload)]
Ops.listJobsByGroup Text
schemaName Text
tableName Text
groupKey Int
limit Int
offset m [JobRead (Stored payload)]
-> ([JobRead (Stored payload)] -> m [JobRead payload])
-> m [JobRead payload]
forall a b. m a -> (a -> m b) -> m b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (JobRead (Stored payload) -> m (JobRead payload))
-> [JobRead (Stored payload)] -> m [JobRead payload]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> [a] -> f [b]
traverse JobRead (Stored payload) -> m (JobRead payload)
forall payload (m :: * -> *).
(FromJSON payload, MonadArbiter m) =>
JobRead (Stored payload) -> m (JobRead payload)
Ops.typedRow
listJobsByParent
:: forall payload m
. (QueueOperation m payload)
=> Int64
-> Int
-> Int
-> m [JobRead payload]
listJobsByParent :: forall payload (m :: * -> *).
QueueOperation m payload =>
Int64 -> Int -> Int -> m [JobRead payload]
listJobsByParent Int64
pid Int
limit Int
offset =
forall payload (m :: * -> *) a.
(KnownSymbol (TableForPayload payload (RegistryOf m)),
MonadArbiter m) =>
(Text -> Text -> m a) -> m a
onQueue @payload ((Text -> Text -> m [JobRead payload]) -> m [JobRead payload])
-> (Text -> Text -> m [JobRead payload]) -> m [JobRead payload]
forall a b. (a -> b) -> a -> b
$ \Text
schemaName Text
tableName ->
Text -> Text -> Int64 -> Int -> Int -> m [JobRead (Stored payload)]
forall (m :: * -> *) payload.
MonadArbiter m =>
Text -> Text -> Int64 -> Int -> Int -> m [JobRead (Stored payload)]
Ops.listJobsByParent Text
schemaName Text
tableName Int64
pid Int
limit Int
offset m [JobRead (Stored payload)]
-> ([JobRead (Stored payload)] -> m [JobRead payload])
-> m [JobRead payload]
forall a b. m a -> (a -> m b) -> m b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (JobRead (Stored payload) -> m (JobRead payload))
-> [JobRead (Stored payload)] -> m [JobRead payload]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> [a] -> f [b]
traverse JobRead (Stored payload) -> m (JobRead payload)
forall payload (m :: * -> *).
(FromJSON payload, MonadArbiter m) =>
JobRead (Stored payload) -> m (JobRead payload)
Ops.typedRow
cancelJob
:: forall payload m
. (QueueOperation m payload)
=> Int64
-> m Int64
cancelJob :: forall payload (m :: * -> *).
QueueOperation m payload =>
Int64 -> m Int64
cancelJob Int64
jobId = forall payload (m :: * -> *) a.
(KnownSymbol (TableForPayload payload (RegistryOf m)),
MonadArbiter m) =>
(Text -> Text -> m a) -> m a
onQueue @payload ((Text -> Text -> m Int64) -> m Int64)
-> (Text -> Text -> m Int64) -> m Int64
forall a b. (a -> b) -> a -> b
$ \Text
schemaName Text
tableName -> Text -> Text -> Int64 -> m Int64
forall (m :: * -> *).
MonadArbiter m =>
Text -> Text -> Int64 -> m Int64
Ops.cancelJob Text
schemaName Text
tableName Int64
jobId
cancelJobsBatch
:: forall payload m
. (QueueOperation m payload)
=> [Int64]
-> m Int64
cancelJobsBatch :: forall payload (m :: * -> *).
QueueOperation m payload =>
[Int64] -> m Int64
cancelJobsBatch [Int64]
jobIds = forall payload (m :: * -> *) a.
(KnownSymbol (TableForPayload payload (RegistryOf m)),
MonadArbiter m) =>
(Text -> Text -> m a) -> m a
onQueue @payload ((Text -> Text -> m Int64) -> m Int64)
-> (Text -> Text -> m Int64) -> m Int64
forall a b. (a -> b) -> a -> b
$ \Text
schemaName Text
tableName -> Text -> Text -> [Int64] -> m Int64
forall (m :: * -> *).
MonadArbiter m =>
Text -> Text -> [Int64] -> m Int64
Ops.cancelJobsBatch Text
schemaName Text
tableName [Int64]
jobIds
forceCancelJob
:: forall payload m
. (QueueOperation m payload)
=> Int64
-> m Int64
forceCancelJob :: forall payload (m :: * -> *).
QueueOperation m payload =>
Int64 -> m Int64
forceCancelJob Int64
jobId = forall payload (m :: * -> *) a.
(KnownSymbol (TableForPayload payload (RegistryOf m)),
MonadArbiter m) =>
(Text -> Text -> m a) -> m a
onQueue @payload ((Text -> Text -> m Int64) -> m Int64)
-> (Text -> Text -> m Int64) -> m Int64
forall a b. (a -> b) -> a -> b
$ \Text
schemaName Text
tableName -> Text -> Text -> Int64 -> m Int64
forall (m :: * -> *).
MonadArbiter m =>
Text -> Text -> Int64 -> m Int64
Ops.forceCancelJob Text
schemaName Text
tableName Int64
jobId
promoteJob
:: forall payload m
. (QueueOperation m payload)
=> Int64
-> m Int64
promoteJob :: forall payload (m :: * -> *).
QueueOperation m payload =>
Int64 -> m Int64
promoteJob Int64
jobId = forall payload (m :: * -> *) a.
(KnownSymbol (TableForPayload payload (RegistryOf m)),
MonadArbiter m) =>
(Text -> Text -> m a) -> m a
onQueue @payload ((Text -> Text -> m Int64) -> m Int64)
-> (Text -> Text -> m Int64) -> m Int64
forall a b. (a -> b) -> a -> b
$ \Text
schemaName Text
tableName -> Text -> Text -> Int64 -> m Int64
forall (m :: * -> *).
MonadArbiter m =>
Text -> Text -> Int64 -> m Int64
Ops.promoteJob Text
schemaName Text
tableName Int64
jobId
rescheduleJob
:: forall payload m
. (QueueOperation m payload)
=> Int64
-> UTCTime
-> m Int64
rescheduleJob :: forall payload (m :: * -> *).
QueueOperation m payload =>
Int64 -> UTCTime -> m Int64
rescheduleJob Int64
jobId UTCTime
runAt =
forall payload (m :: * -> *) a.
(KnownSymbol (TableForPayload payload (RegistryOf m)),
MonadArbiter m) =>
(Text -> Text -> m a) -> m a
onQueue @payload ((Text -> Text -> m Int64) -> m Int64)
-> (Text -> Text -> m Int64) -> m Int64
forall a b. (a -> b) -> a -> b
$ \Text
schemaName Text
tableName ->
Text -> Text -> Int64 -> UTCTime -> m Int64
forall (m :: * -> *).
MonadArbiter m =>
Text -> Text -> Int64 -> UTCTime -> m Int64
Ops.rescheduleJob Text
schemaName Text
tableName Int64
jobId UTCTime
runAt
getQueueStats
:: forall payload m
. (QueueOperation m payload)
=> m Ops.QueueStats
getQueueStats :: forall payload (m :: * -> *).
QueueOperation m payload =>
m QueueStats
getQueueStats = forall payload (m :: * -> *) a.
(KnownSymbol (TableForPayload payload (RegistryOf m)),
MonadArbiter m) =>
(Text -> Text -> m a) -> m a
onQueue @payload ((Text -> Text -> m QueueStats) -> m QueueStats)
-> (Text -> Text -> m QueueStats) -> m QueueStats
forall a b. (a -> b) -> a -> b
$ \Text
schemaName Text
tableName -> Text -> Text -> [Text] -> m QueueStats
forall (m :: * -> *).
MonadArbiter m =>
Text -> Text -> [Text] -> m QueueStats
Ops.getQueueStats Text
schemaName Text
tableName (forall payload. HasKind payload => [Text]
kindsFor @payload)
countJobs
:: forall payload m
. (QueueOperation m payload)
=> m Int64
countJobs :: forall payload (m :: * -> *). QueueOperation m payload => m Int64
countJobs = forall payload (m :: * -> *) a.
(KnownSymbol (TableForPayload payload (RegistryOf m)),
MonadArbiter m) =>
(Text -> Text -> m a) -> m a
onQueue @payload Text -> Text -> m Int64
forall (m :: * -> *). MonadArbiter m => Text -> Text -> m Int64
Ops.countJobs
countJobsByGroup
:: forall payload m
. (QueueOperation m payload)
=> Text
-> m Int64
countJobsByGroup :: forall payload (m :: * -> *).
QueueOperation m payload =>
Text -> m Int64
countJobsByGroup Text
groupKey =
forall payload (m :: * -> *) a.
(KnownSymbol (TableForPayload payload (RegistryOf m)),
MonadArbiter m) =>
(Text -> Text -> m a) -> m a
onQueue @payload ((Text -> Text -> m Int64) -> m Int64)
-> (Text -> Text -> m Int64) -> m Int64
forall a b. (a -> b) -> a -> b
$ \Text
schemaName Text
tableName ->
Text -> Text -> Text -> m Int64
forall (m :: * -> *).
MonadArbiter m =>
Text -> Text -> Text -> m Int64
Ops.countJobsByGroup Text
schemaName Text
tableName Text
groupKey
countJobsByParent
:: forall payload m
. (QueueOperation m payload)
=> Int64
-> m Int64
countJobsByParent :: forall payload (m :: * -> *).
QueueOperation m payload =>
Int64 -> m Int64
countJobsByParent Int64
pid = forall payload (m :: * -> *) a.
(KnownSymbol (TableForPayload payload (RegistryOf m)),
MonadArbiter m) =>
(Text -> Text -> m a) -> m a
onQueue @payload ((Text -> Text -> m Int64) -> m Int64)
-> (Text -> Text -> m Int64) -> m Int64
forall a b. (a -> b) -> a -> b
$ \Text
schemaName Text
tableName -> Text -> Text -> Int64 -> m Int64
forall (m :: * -> *).
MonadArbiter m =>
Text -> Text -> Int64 -> m Int64
Ops.countJobsByParent Text
schemaName Text
tableName Int64
pid
countDLQJobs
:: forall payload m
. (QueueOperation m payload)
=> m Int64
countDLQJobs :: forall payload (m :: * -> *). QueueOperation m payload => m Int64
countDLQJobs = forall payload (m :: * -> *) a.
(KnownSymbol (TableForPayload payload (RegistryOf m)),
MonadArbiter m) =>
(Text -> Text -> m a) -> m a
onQueue @payload Text -> Text -> m Int64
forall (m :: * -> *). MonadArbiter m => Text -> Text -> m Int64
Ops.countDLQJobs
countChildrenBatch
:: forall payload m
. (QueueOperation m payload)
=> [Int64]
-> m (Map Int64 (Int64, Int64))
countChildrenBatch :: forall payload (m :: * -> *).
QueueOperation m payload =>
[Int64] -> m (Map Int64 (Int64, Int64))
countChildrenBatch [Int64]
ids = forall payload (m :: * -> *) a.
(KnownSymbol (TableForPayload payload (RegistryOf m)),
MonadArbiter m) =>
(Text -> Text -> m a) -> m a
onQueue @payload ((Text -> Text -> m (Map Int64 (Int64, Int64)))
-> m (Map Int64 (Int64, Int64)))
-> (Text -> Text -> m (Map Int64 (Int64, Int64)))
-> m (Map Int64 (Int64, Int64))
forall a b. (a -> b) -> a -> b
$ \Text
schemaName Text
tableName -> Text -> Text -> [Int64] -> m (Map Int64 (Int64, Int64))
forall (m :: * -> *).
MonadArbiter m =>
Text -> Text -> [Int64] -> m (Map Int64 (Int64, Int64))
Ops.countChildrenBatch Text
schemaName Text
tableName [Int64]
ids
countDLQChildren
:: forall payload m
. (QueueOperation m payload)
=> Int64
-> m Int64
countDLQChildren :: forall payload (m :: * -> *).
QueueOperation m payload =>
Int64 -> m Int64
countDLQChildren Int64
parentJobId =
Int64 -> Int64 -> Map Int64 Int64 -> Int64
forall k a. Ord k => a -> k -> Map k a -> a
Map.findWithDefault Int64
0 Int64
parentJobId (Map Int64 Int64 -> Int64) -> m (Map Int64 Int64) -> m Int64
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall payload (m :: * -> *).
QueueOperation m payload =>
[Int64] -> m (Map Int64 Int64)
countDLQChildrenBatch @payload [Int64
parentJobId]
countDLQChildrenBatch
:: forall payload m
. (QueueOperation m payload)
=> [Int64]
-> m (Map Int64 Int64)
countDLQChildrenBatch :: forall payload (m :: * -> *).
QueueOperation m payload =>
[Int64] -> m (Map Int64 Int64)
countDLQChildrenBatch [Int64]
ids =
forall payload (m :: * -> *) a.
(KnownSymbol (TableForPayload payload (RegistryOf m)),
MonadArbiter m) =>
(Text -> Text -> m a) -> m a
onQueue @payload ((Text -> Text -> m (Map Int64 Int64)) -> m (Map Int64 Int64))
-> (Text -> Text -> m (Map Int64 Int64)) -> m (Map Int64 Int64)
forall a b. (a -> b) -> a -> b
$ \Text
schemaName Text
tableName ->
Text -> Text -> [Int64] -> m (Map Int64 Int64)
forall (m :: * -> *).
MonadArbiter m =>
Text -> Text -> [Int64] -> m (Map Int64 Int64)
Ops.countDLQChildrenBatch Text
schemaName Text
tableName [Int64]
ids
pauseChildren
:: forall payload m
. (QueueOperation m payload)
=> Int64
-> m Int64
pauseChildren :: forall payload (m :: * -> *).
QueueOperation m payload =>
Int64 -> m Int64
pauseChildren Int64
parentJobId =
forall payload (m :: * -> *) a.
(KnownSymbol (TableForPayload payload (RegistryOf m)),
MonadArbiter m) =>
(Text -> Text -> m a) -> m a
onQueue @payload ((Text -> Text -> m Int64) -> m Int64)
-> (Text -> Text -> m Int64) -> m Int64
forall a b. (a -> b) -> a -> b
$ \Text
schemaName Text
tableName ->
Text -> Text -> Int64 -> m Int64
forall (m :: * -> *).
MonadArbiter m =>
Text -> Text -> Int64 -> m Int64
Ops.pauseChildren Text
schemaName Text
tableName Int64
parentJobId
resumeChildren
:: forall payload m
. (QueueOperation m payload)
=> Int64
-> m Int64
resumeChildren :: forall payload (m :: * -> *).
QueueOperation m payload =>
Int64 -> m Int64
resumeChildren Int64
parentJobId =
forall payload (m :: * -> *) a.
(KnownSymbol (TableForPayload payload (RegistryOf m)),
MonadArbiter m) =>
(Text -> Text -> m a) -> m a
onQueue @payload ((Text -> Text -> m Int64) -> m Int64)
-> (Text -> Text -> m Int64) -> m Int64
forall a b. (a -> b) -> a -> b
$ \Text
schemaName Text
tableName ->
Text -> Text -> Int64 -> m Int64
forall (m :: * -> *).
MonadArbiter m =>
Text -> Text -> Int64 -> m Int64
Ops.resumeChildren Text
schemaName Text
tableName Int64
parentJobId
cancelJobCascade
:: forall payload m
. (QueueOperation m payload)
=> Int64
-> m Int64
cancelJobCascade :: forall payload (m :: * -> *).
QueueOperation m payload =>
Int64 -> m Int64
cancelJobCascade Int64
jobId =
forall payload (m :: * -> *) a.
(KnownSymbol (TableForPayload payload (RegistryOf m)),
MonadArbiter m) =>
(Text -> Text -> m a) -> m a
onQueue @payload ((Text -> Text -> m Int64) -> m Int64)
-> (Text -> Text -> m Int64) -> m Int64
forall a b. (a -> b) -> a -> b
$ \Text
schemaName Text
tableName ->
[Int64] -> Int64
forall i a. Num i => [a] -> i
genericLength ([Int64] -> Int64) -> m [Int64] -> m Int64
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Text -> Text -> Int64 -> m [Int64]
forall (m :: * -> *).
MonadArbiter m =>
Text -> Text -> Int64 -> m [Int64]
Ops.cancelJobCascade Text
schemaName Text
tableName Int64
jobId
suspendJob
:: forall payload m
. (QueueOperation m payload)
=> Int64
-> m Int64
suspendJob :: forall payload (m :: * -> *).
QueueOperation m payload =>
Int64 -> m Int64
suspendJob Int64
jobId = forall payload (m :: * -> *) a.
(KnownSymbol (TableForPayload payload (RegistryOf m)),
MonadArbiter m) =>
(Text -> Text -> m a) -> m a
onQueue @payload ((Text -> Text -> m Int64) -> m Int64)
-> (Text -> Text -> m Int64) -> m Int64
forall a b. (a -> b) -> a -> b
$ \Text
schemaName Text
tableName -> Text -> Text -> Int64 -> m Int64
forall (m :: * -> *).
MonadArbiter m =>
Text -> Text -> Int64 -> m Int64
Ops.suspendJob Text
schemaName Text
tableName Int64
jobId
resumeJob
:: forall payload m
. (QueueOperation m payload)
=> Int64
-> m Int64
resumeJob :: forall payload (m :: * -> *).
QueueOperation m payload =>
Int64 -> m Int64
resumeJob Int64
jobId = forall payload (m :: * -> *) a.
(KnownSymbol (TableForPayload payload (RegistryOf m)),
MonadArbiter m) =>
(Text -> Text -> m a) -> m a
onQueue @payload ((Text -> Text -> m Int64) -> m Int64)
-> (Text -> Text -> m Int64) -> m Int64
forall a b. (a -> b) -> a -> b
$ \Text
schemaName Text
tableName -> Text -> Text -> Int64 -> m Int64
forall (m :: * -> *).
MonadArbiter m =>
Text -> Text -> Int64 -> m Int64
Ops.resumeJob Text
schemaName Text
tableName Int64
jobId
insertResult
:: forall payload m
. (EncodeJobResult (ResultOf m payload), QueueOperation m payload)
=> Int64
-> Int64
-> ResultOf m payload
-> m Int64
insertResult :: forall payload (m :: * -> *).
(EncodeJobResult (ResultOf m payload), QueueOperation m payload) =>
Int64 -> Int64 -> ResultOf m payload -> m Int64
insertResult Int64
parentJobId Int64
childId ResultOf m payload
result =
m Int64 -> (Value -> m Int64) -> Maybe Value -> m Int64
forall b a. b -> (a -> b) -> Maybe a -> b
maybe (Int64 -> m Int64
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Int64
0) (forall payload (m :: * -> *).
QueueOperation m payload =>
Int64 -> Int64 -> Value -> m Int64
insertResultUnsafe @payload Int64
parentJobId Int64
childId) (SpecResult (MatchIn payload '[] (RegistryOf m)) -> Maybe Value
forall a. EncodeJobResult a => a -> Maybe Value
encodeJobResult ResultOf m payload
SpecResult (MatchIn payload '[] (RegistryOf m))
result)
insertResultUnsafe
:: forall payload m
. (QueueOperation m payload)
=> Int64
-> Int64
-> Value
-> m Int64
insertResultUnsafe :: forall payload (m :: * -> *).
QueueOperation m payload =>
Int64 -> Int64 -> Value -> m Int64
insertResultUnsafe Int64
parentJobId Int64
childId Value
result =
forall payload (m :: * -> *) a.
(KnownSymbol (TableForPayload payload (RegistryOf m)),
MonadArbiter m) =>
(Text -> Text -> m a) -> m a
onQueue @payload ((Text -> Text -> m Int64) -> m Int64)
-> (Text -> Text -> m Int64) -> m Int64
forall a b. (a -> b) -> a -> b
$ \Text
schemaName Text
tableName ->
Text -> Text -> Int64 -> Int64 -> Value -> m Int64
forall (m :: * -> *).
MonadArbiter m =>
Text -> Text -> Int64 -> Int64 -> Value -> m Int64
Ops.insertResult Text
schemaName Text
tableName Int64
parentJobId Int64
childId Value
result
getResultsByParent
:: forall payload m
. (QueueOperation m payload)
=> Int64
-> m (Map Int64 Value)
getResultsByParent :: forall payload (m :: * -> *).
QueueOperation m payload =>
Int64 -> m (Map Int64 Value)
getResultsByParent Int64
parentJobId =
forall payload (m :: * -> *) a.
(KnownSymbol (TableForPayload payload (RegistryOf m)),
MonadArbiter m) =>
(Text -> Text -> m a) -> m a
onQueue @payload ((Text -> Text -> m (Map Int64 Value)) -> m (Map Int64 Value))
-> (Text -> Text -> m (Map Int64 Value)) -> m (Map Int64 Value)
forall a b. (a -> b) -> a -> b
$ \Text
schemaName Text
tableName ->
Text -> Text -> Int64 -> m (Map Int64 Value)
forall (m :: * -> *).
MonadArbiter m =>
Text -> Text -> Int64 -> m (Map Int64 Value)
Ops.getResultsByParent Text
schemaName Text
tableName Int64
parentJobId
getDLQChildErrorsByParent
:: forall payload m
. (QueueOperation m payload)
=> Int64
-> m (Map Int64 Text)
getDLQChildErrorsByParent :: forall payload (m :: * -> *).
QueueOperation m payload =>
Int64 -> m (Map Int64 Text)
getDLQChildErrorsByParent Int64
parentJobId =
forall payload (m :: * -> *) a.
(KnownSymbol (TableForPayload payload (RegistryOf m)),
MonadArbiter m) =>
(Text -> Text -> m a) -> m a
onQueue @payload ((Text -> Text -> m (Map Int64 Text)) -> m (Map Int64 Text))
-> (Text -> Text -> m (Map Int64 Text)) -> m (Map Int64 Text)
forall a b. (a -> b) -> a -> b
$ \Text
schemaName Text
tableName ->
Text -> Text -> Int64 -> m (Map Int64 Text)
forall (m :: * -> *).
MonadArbiter m =>
Text -> Text -> Int64 -> m (Map Int64 Text)
Ops.getDLQChildErrorsByParent Text
schemaName Text
tableName Int64
parentJobId
readChildResultsRaw
:: forall payload m
. (QueueOperation m payload)
=> Int64
-> m (Map Int64 Value, Map Int64 Text, Maybe Value, Map Int64 Text)
readChildResultsRaw :: forall payload (m :: * -> *).
QueueOperation m payload =>
Int64
-> m (Map Int64 Value, Map Int64 Text, Maybe Value, Map Int64 Text)
readChildResultsRaw Int64
parentJobId =
forall payload (m :: * -> *) a.
(KnownSymbol (TableForPayload payload (RegistryOf m)),
MonadArbiter m) =>
(Text -> Text -> m a) -> m a
onQueue @payload ((Text
-> Text
-> m (Map Int64 Value, Map Int64 Text, Maybe Value,
Map Int64 Text))
-> m (Map Int64 Value, Map Int64 Text, Maybe Value,
Map Int64 Text))
-> (Text
-> Text
-> m (Map Int64 Value, Map Int64 Text, Maybe Value,
Map Int64 Text))
-> m (Map Int64 Value, Map Int64 Text, Maybe Value, Map Int64 Text)
forall a b. (a -> b) -> a -> b
$ \Text
schemaName Text
tableName ->
Text
-> Text
-> Int64
-> m (Map Int64 Value, Map Int64 Text, Maybe Value, Map Int64 Text)
forall (m :: * -> *).
MonadArbiter m =>
Text
-> Text
-> Int64
-> m (Map Int64 Value, Map Int64 Text, Maybe Value, Map Int64 Text)
Ops.readChildResultsRaw Text
schemaName Text
tableName Int64
parentJobId
persistParentState
:: forall payload m
. (QueueOperation m payload)
=> Int64
-> Value
-> m Int64
persistParentState :: forall payload (m :: * -> *).
QueueOperation m payload =>
Int64 -> Value -> m Int64
persistParentState Int64
jobId Value
state =
forall payload (m :: * -> *) a.
(KnownSymbol (TableForPayload payload (RegistryOf m)),
MonadArbiter m) =>
(Text -> Text -> m a) -> m a
onQueue @payload ((Text -> Text -> m Int64) -> m Int64)
-> (Text -> Text -> m Int64) -> m Int64
forall a b. (a -> b) -> a -> b
$ \Text
schemaName Text
tableName ->
Text -> Text -> Int64 -> Value -> m Int64
forall (m :: * -> *).
MonadArbiter m =>
Text -> Text -> Int64 -> Value -> m Int64
Ops.persistParentState Text
schemaName Text
tableName Int64
jobId Value
state
getParentStateSnapshot
:: forall payload m
. (QueueOperation m payload)
=> Int64
-> m (Maybe Value)
getParentStateSnapshot :: forall payload (m :: * -> *).
QueueOperation m payload =>
Int64 -> m (Maybe Value)
getParentStateSnapshot Int64
jobId =
forall payload (m :: * -> *) a.
(KnownSymbol (TableForPayload payload (RegistryOf m)),
MonadArbiter m) =>
(Text -> Text -> m a) -> m a
onQueue @payload ((Text -> Text -> m (Maybe Value)) -> m (Maybe Value))
-> (Text -> Text -> m (Maybe Value)) -> m (Maybe Value)
forall a b. (a -> b) -> a -> b
$ \Text
schemaName Text
tableName ->
Text -> Text -> Int64 -> m (Maybe Value)
forall (m :: * -> *).
MonadArbiter m =>
Text -> Text -> Int64 -> m (Maybe Value)
Ops.getParentStateSnapshot Text
schemaName Text
tableName Int64
jobId
refreshAllGroupsFully
:: forall m
. (MonadArbiter m, RegistryTables (RegistryOf m))
=> m (Int64, [Text])
refreshAllGroupsFully :: forall (m :: * -> *).
(MonadArbiter m, RegistryTables (RegistryOf m)) =>
m (Int64, [Text])
refreshAllGroupsFully = (Text -> [Text] -> m (Int64, [Text])) -> m (Int64, [Text])
forall (m :: * -> *) a.
(MonadArbiter m, RegistryTables (RegistryOf m)) =>
(Text -> [Text] -> m a) -> m a
onRegistry Text -> [Text] -> m (Int64, [Text])
forall (m :: * -> *).
MonadArbiter m =>
Text -> [Text] -> m (Int64, [Text])
Ops.refreshAllGroupsFully
registerWorker
:: (MonadArbiter m)
=> UUID
-> Text
-> Maybe Text
-> Maybe Int32
-> NominalDiffTime
-> Maybe Value
-> m (Maybe Bool)
registerWorker :: forall (m :: * -> *).
MonadArbiter m =>
UUID
-> Text
-> Maybe Text
-> Maybe Int32
-> NominalDiffTime
-> Maybe Value
-> m (Maybe Bool)
registerWorker UUID
workerId Text
queue Maybe Text
host Maybe Int32
threads NominalDiffTime
staleThreshold Maybe Value
metadata =
(Text -> m (Maybe Bool)) -> m (Maybe Bool)
forall (m :: * -> *) a. MonadArbiter m => (Text -> m a) -> m a
onSchema ((Text -> m (Maybe Bool)) -> m (Maybe Bool))
-> (Text -> m (Maybe Bool)) -> m (Maybe Bool)
forall a b. (a -> b) -> a -> b
$ \Text
schemaName -> Text
-> UUID
-> Text
-> Maybe Text
-> Maybe Int32
-> NominalDiffTime
-> Maybe Value
-> m (Maybe Bool)
forall (m :: * -> *).
MonadArbiter m =>
Text
-> UUID
-> Text
-> Maybe Text
-> Maybe Int32
-> NominalDiffTime
-> Maybe Value
-> m (Maybe Bool)
Ops.registerWorker Text
schemaName UUID
workerId Text
queue Maybe Text
host Maybe Int32
threads NominalDiffTime
staleThreshold Maybe Value
metadata
heartbeatWorker :: (MonadArbiter m) => UUID -> m (Maybe Bool)
heartbeatWorker :: forall (m :: * -> *). MonadArbiter m => UUID -> m (Maybe Bool)
heartbeatWorker UUID
workerId = (Text -> m (Maybe Bool)) -> m (Maybe Bool)
forall (m :: * -> *) a. MonadArbiter m => (Text -> m a) -> m a
onSchema ((Text -> m (Maybe Bool)) -> m (Maybe Bool))
-> (Text -> m (Maybe Bool)) -> m (Maybe Bool)
forall a b. (a -> b) -> a -> b
$ \Text
schemaName -> Text -> UUID -> m (Maybe Bool)
forall (m :: * -> *).
MonadArbiter m =>
Text -> UUID -> m (Maybe Bool)
Ops.heartbeatWorker Text
schemaName UUID
workerId
setWorkerPaused :: (MonadArbiter m) => UUID -> Bool -> m Int64
setWorkerPaused :: forall (m :: * -> *). MonadArbiter m => UUID -> Bool -> m Int64
setWorkerPaused UUID
workerId Bool
paused = (Text -> m Int64) -> m Int64
forall (m :: * -> *) a. MonadArbiter m => (Text -> m a) -> m a
onSchema ((Text -> m Int64) -> m Int64) -> (Text -> m Int64) -> m Int64
forall a b. (a -> b) -> a -> b
$ \Text
schemaName -> Text -> UUID -> Bool -> m Int64
forall (m :: * -> *).
MonadArbiter m =>
Text -> UUID -> Bool -> m Int64
Ops.setWorkerPaused Text
schemaName UUID
workerId Bool
paused
markWorkerShuttingDown :: (MonadArbiter m) => UUID -> m Int64
markWorkerShuttingDown :: forall (m :: * -> *). MonadArbiter m => UUID -> m Int64
markWorkerShuttingDown UUID
workerId = (Text -> m Int64) -> m Int64
forall (m :: * -> *) a. MonadArbiter m => (Text -> m a) -> m a
onSchema ((Text -> m Int64) -> m Int64) -> (Text -> m Int64) -> m Int64
forall a b. (a -> b) -> a -> b
$ \Text
schemaName -> Text -> UUID -> m Int64
forall (m :: * -> *). MonadArbiter m => Text -> UUID -> m Int64
Ops.markWorkerShuttingDown Text
schemaName UUID
workerId
deregisterWorker :: (MonadArbiter m) => UUID -> m Int64
deregisterWorker :: forall (m :: * -> *). MonadArbiter m => UUID -> m Int64
deregisterWorker UUID
workerId = (Text -> m Int64) -> m Int64
forall (m :: * -> *) a. MonadArbiter m => (Text -> m a) -> m a
onSchema ((Text -> m Int64) -> m Int64) -> (Text -> m Int64) -> m Int64
forall a b. (a -> b) -> a -> b
$ \Text
schemaName -> Text -> UUID -> m Int64
forall (m :: * -> *). MonadArbiter m => Text -> UUID -> m Int64
Ops.deregisterWorker Text
schemaName UUID
workerId
listWorkers :: (MonadArbiter m) => Maybe Text -> Maybe NominalDiffTime -> m [WorkerRow]
listWorkers :: forall (m :: * -> *).
MonadArbiter m =>
Maybe Text -> Maybe NominalDiffTime -> m [WorkerRow]
listWorkers Maybe Text
queue Maybe NominalDiffTime
liveSecs = (Text -> m [WorkerRow]) -> m [WorkerRow]
forall (m :: * -> *) a. MonadArbiter m => (Text -> m a) -> m a
onSchema ((Text -> m [WorkerRow]) -> m [WorkerRow])
-> (Text -> m [WorkerRow]) -> m [WorkerRow]
forall a b. (a -> b) -> a -> b
$ \Text
schemaName -> Text -> Maybe Text -> Maybe NominalDiffTime -> m [WorkerRow]
forall (m :: * -> *).
MonadArbiter m =>
Text -> Maybe Text -> Maybe NominalDiffTime -> m [WorkerRow]
Ops.listWorkers Text
schemaName Maybe Text
queue Maybe NominalDiffTime
liveSecs
sweepStaleWorkers :: (MonadArbiter m) => m Int64
sweepStaleWorkers :: forall (m :: * -> *). MonadArbiter m => m Int64
sweepStaleWorkers = (Text -> m Int64) -> m Int64
forall (m :: * -> *) a. MonadArbiter m => (Text -> m a) -> m a
onSchema Text -> m Int64
forall (m :: * -> *). MonadArbiter m => Text -> m Int64
Ops.sweepStaleWorkers
ensureQueue :: (MonadArbiter m) => Text -> m Int64
ensureQueue :: forall (m :: * -> *). MonadArbiter m => Text -> m Int64
ensureQueue Text
queue = (Text -> m Int64) -> m Int64
forall (m :: * -> *) a. MonadArbiter m => (Text -> m a) -> m a
onSchema ((Text -> m Int64) -> m Int64) -> (Text -> m Int64) -> m Int64
forall a b. (a -> b) -> a -> b
$ \Text
schemaName -> Text -> Text -> m Int64
forall (m :: * -> *). MonadArbiter m => Text -> Text -> m Int64
Ops.ensureQueue Text
schemaName Text
queue
setQueuePaused :: (MonadArbiter m) => Text -> Bool -> m Int64
setQueuePaused :: forall (m :: * -> *). MonadArbiter m => Text -> Bool -> m Int64
setQueuePaused Text
queue Bool
paused = (Text -> m Int64) -> m Int64
forall (m :: * -> *) a. MonadArbiter m => (Text -> m a) -> m a
onSchema ((Text -> m Int64) -> m Int64) -> (Text -> m Int64) -> m Int64
forall a b. (a -> b) -> a -> b
$ \Text
schemaName -> Text -> Text -> Bool -> m Int64
forall (m :: * -> *).
MonadArbiter m =>
Text -> Text -> Bool -> m Int64
Ops.setQueuePaused Text
schemaName Text
queue Bool
paused
setQueueDLQRetention :: (MonadArbiter m) => Text -> Maybe NominalDiffTime -> m ()
setQueueDLQRetention :: forall (m :: * -> *).
MonadArbiter m =>
Text -> Maybe NominalDiffTime -> m ()
setQueueDLQRetention Text
queue Maybe NominalDiffTime
retention = (Text -> m ()) -> m ()
forall (m :: * -> *) a. MonadArbiter m => (Text -> m a) -> m a
onSchema ((Text -> m ()) -> m ()) -> (Text -> m ()) -> m ()
forall a b. (a -> b) -> a -> b
$ \Text
schemaName -> Text -> Text -> Maybe NominalDiffTime -> m ()
forall (m :: * -> *).
MonadArbiter m =>
Text -> Text -> Maybe NominalDiffTime -> m ()
Ops.setQueueDLQRetention Text
schemaName Text
queue Maybe NominalDiffTime
retention
getQueue :: (MonadArbiter m) => Text -> m (Maybe QueueRow)
getQueue :: forall (m :: * -> *). MonadArbiter m => Text -> m (Maybe QueueRow)
getQueue Text
queue = (Text -> m (Maybe QueueRow)) -> m (Maybe QueueRow)
forall (m :: * -> *) a. MonadArbiter m => (Text -> m a) -> m a
onSchema ((Text -> m (Maybe QueueRow)) -> m (Maybe QueueRow))
-> (Text -> m (Maybe QueueRow)) -> m (Maybe QueueRow)
forall a b. (a -> b) -> a -> b
$ \Text
schemaName -> Text -> Text -> m (Maybe QueueRow)
forall (m :: * -> *).
MonadArbiter m =>
Text -> Text -> m (Maybe QueueRow)
Ops.getQueue Text
schemaName Text
queue
listQueues :: (MonadArbiter m) => m [QueueRow]
listQueues :: forall (m :: * -> *). MonadArbiter m => m [QueueRow]
listQueues = (Text -> m [QueueRow]) -> m [QueueRow]
forall (m :: * -> *) a. MonadArbiter m => (Text -> m a) -> m a
onSchema Text -> m [QueueRow]
forall (m :: * -> *). MonadArbiter m => Text -> m [QueueRow]
Ops.listQueues
listCronSchedules
:: forall m
. (MonadArbiter m)
=> Maybe Text
-> m [CronScheduleRow]
listCronSchedules :: forall (m :: * -> *).
MonadArbiter m =>
Maybe Text -> m [CronScheduleRow]
listCronSchedules Maybe Text
mQueue = (Text -> m [CronScheduleRow]) -> m [CronScheduleRow]
forall (m :: * -> *) a. MonadArbiter m => (Text -> m a) -> m a
onSchema ((Text -> m [CronScheduleRow]) -> m [CronScheduleRow])
-> (Text -> m [CronScheduleRow]) -> m [CronScheduleRow]
forall a b. (a -> b) -> a -> b
$ \Text
schemaName -> Text -> Maybe Text -> m [CronScheduleRow]
forall (m :: * -> *).
MonadArbiter m =>
Text -> Maybe Text -> m [CronScheduleRow]
Ops.listCronSchedules Text
schemaName Maybe Text
mQueue
getCronScheduleByName
:: forall m
. (MonadArbiter m)
=> Text
-> m (Maybe CronScheduleRow)
getCronScheduleByName :: forall (m :: * -> *).
MonadArbiter m =>
Text -> m (Maybe CronScheduleRow)
getCronScheduleByName Text
scheduleName = (Text -> m (Maybe CronScheduleRow)) -> m (Maybe CronScheduleRow)
forall (m :: * -> *) a. MonadArbiter m => (Text -> m a) -> m a
onSchema ((Text -> m (Maybe CronScheduleRow)) -> m (Maybe CronScheduleRow))
-> (Text -> m (Maybe CronScheduleRow)) -> m (Maybe CronScheduleRow)
forall a b. (a -> b) -> a -> b
$ \Text
schemaName -> Text -> Text -> m (Maybe CronScheduleRow)
forall (m :: * -> *).
MonadArbiter m =>
Text -> Text -> m (Maybe CronScheduleRow)
Ops.getCronScheduleByName Text
schemaName Text
scheduleName
updateCronScheduleUnchecked
:: forall m
. (MonadArbiter m)
=> Text
-> CronScheduleUpdate
-> m Int64
updateCronScheduleUnchecked :: forall (m :: * -> *).
MonadArbiter m =>
Text -> CronScheduleUpdate -> m Int64
updateCronScheduleUnchecked Text
scheduleName CronScheduleUpdate
upd =
(Text -> m Int64) -> m Int64
forall (m :: * -> *) a. MonadArbiter m => (Text -> m a) -> m a
onSchema ((Text -> m Int64) -> m Int64) -> (Text -> m Int64) -> m Int64
forall a b. (a -> b) -> a -> b
$ \Text
schemaName ->
Text -> Text -> CronScheduleUpdate -> m Int64
forall (m :: * -> *).
MonadArbiter m =>
Text -> Text -> CronScheduleUpdate -> m Int64
Ops.updateCronSchedule Text
schemaName Text
scheduleName CronScheduleUpdate
upd
runGated
:: forall m a
. (MonadArbiter m)
=> Text
-> NominalDiffTime
-> m a
-> m (Maybe a)
runGated :: forall (m :: * -> *) a.
MonadArbiter m =>
Text -> NominalDiffTime -> m a -> m (Maybe a)
runGated Text
task NominalDiffTime
interval m a
work = (Text -> m (Maybe a)) -> m (Maybe a)
forall (m :: * -> *) a. MonadArbiter m => (Text -> m a) -> m a
onSchema ((Text -> m (Maybe a)) -> m (Maybe a))
-> (Text -> m (Maybe a)) -> m (Maybe a)
forall a b. (a -> b) -> a -> b
$ \Text
schemaName -> Text -> Text -> NominalDiffTime -> m a -> m (Maybe a)
forall (m :: * -> *) a.
MonadArbiter m =>
Text -> Text -> NominalDiffTime -> m a -> m (Maybe a)
Ops.runGated Text
schemaName Text
task NominalDiffTime
interval m a
work
insertJobTree
:: forall payload m
. (QueueOperation m payload)
=> JT.JobTree payload
-> m (Either Text (NonEmpty (JobRead payload)))
insertJobTree :: forall payload (m :: * -> *).
QueueOperation m payload =>
JobTree payload -> m (Either Text (NonEmpty (JobRead payload)))
insertJobTree JobTree payload
tree = forall payload (m :: * -> *) a.
(KnownSymbol (TableForPayload payload (RegistryOf m)),
MonadArbiter m) =>
(Text -> Text -> m a) -> m a
onQueue @payload ((Text -> Text -> m (Either Text (NonEmpty (JobRead payload))))
-> m (Either Text (NonEmpty (JobRead payload))))
-> (Text -> Text -> m (Either Text (NonEmpty (JobRead payload))))
-> m (Either Text (NonEmpty (JobRead payload)))
forall a b. (a -> b) -> a -> b
$ \Text
schemaName Text
tableName -> Text
-> Text
-> JobTree payload
-> m (Either Text (NonEmpty (JobRead payload)))
forall (m :: * -> *) payload.
(JobPayload payload, MonadArbiter m) =>
Text
-> Text
-> JobTree payload
-> m (Either Text (NonEmpty (JobRead payload)))
JT.insertJobTree Text
schemaName Text
tableName JobTree payload
tree
spawnChildren
:: forall payload m
. (JobOperation m payload)
=> JobRead payload
-> NonEmpty (JobWrite payload)
-> m (NonEmpty (JobRead payload))
spawnChildren :: forall payload (m :: * -> *).
JobOperation m payload =>
JobRead payload
-> NonEmpty (JobWrite payload) -> m (NonEmpty (JobRead payload))
spawnChildren JobRead payload
job NonEmpty (JobWrite payload)
children =
Text
-> [JobWrite payload]
-> m (NonEmpty (JobRead payload))
-> m (NonEmpty (JobRead payload))
forall payload (m :: * -> *) a.
(HasKind payload, MonadUnliftIO m) =>
Text -> [JobWrite payload] -> m a -> m a
withPublishSpan (JobRead payload -> Text
forall payload key q insertedAt adm.
Job payload key q insertedAt adm -> q
Job.queueName JobRead payload
job) (NonEmpty (JobWrite payload) -> [JobWrite payload]
forall a. NonEmpty a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList NonEmpty (JobWrite payload)
children) (m (NonEmpty (JobRead payload)) -> m (NonEmpty (JobRead payload)))
-> m (NonEmpty (JobRead payload)) -> m (NonEmpty (JobRead payload))
forall a b. (a -> b) -> a -> b
$
JobRead payload
-> (Text -> Text -> m (NonEmpty (JobRead payload)))
-> m (NonEmpty (JobRead payload))
forall (m :: * -> *) payload a.
MonadArbiter m =>
JobRead payload -> (Text -> Text -> m a) -> m a
onJob JobRead payload
job ((Text -> Text -> m (NonEmpty (JobRead payload)))
-> m (NonEmpty (JobRead payload)))
-> (Text -> Text -> m (NonEmpty (JobRead payload)))
-> m (NonEmpty (JobRead payload))
forall a b. (a -> b) -> a -> b
$
\Text
schemaName Text
tableName -> Text
-> Text
-> JobRead payload
-> NonEmpty (JobWrite payload)
-> m (NonEmpty (JobRead payload))
forall (m :: * -> *) payload.
(JobPayload payload, MonadArbiter m) =>
Text
-> Text
-> JobRead payload
-> NonEmpty (JobWrite payload)
-> m (NonEmpty (JobRead payload))
Ops.spawnChildren Text
schemaName Text
tableName JobRead payload
job NonEmpty (JobWrite payload)
children