| Safe Haskell | None |
|---|---|
| Language | GHC2024 |
Arbiter.Core.Job.Types
Synopsis
- data Job payload key q insertedAt = Job {
- primaryKey :: key
- payload :: payload
- queueName :: q
- groupKey :: Maybe Text
- insertedAt :: insertedAt
- updatedAt :: Maybe UTCTime
- attempts :: Int32
- lastError :: Maybe Text
- priority :: Int32
- lastAttemptedAt :: Maybe UTCTime
- notVisibleUntil :: Maybe UTCTime
- dedupKey :: Maybe DedupKey
- maxAttempts :: Maybe Int32
- parentId :: Maybe Int64
- parentState :: Maybe Value
- suspended :: Bool
- type JobRead payload = Job payload Int64 Text UTCTime
- type JobWrite payload = Job payload () () ()
- defaultJob :: payload -> JobWrite payload
- defaultGroupedJob :: Text -> payload -> JobWrite payload
- isRollup :: Job p k q t -> Bool
- type JobPayload payload = (FromJSON payload, ToJSON payload)
- data DedupKey
- data ObservabilityHooks (m :: Type -> Type) payload = ObservabilityHooks {
- onJobClaimed :: JobPayload payload => JobRead payload -> ClaimTime -> m ()
- onJobSuccess :: JobPayload payload => JobRead payload -> StartTime -> EndTime -> m ()
- onJobFailure :: JobPayload payload => JobRead payload -> ErrorMsg -> StartTime -> EndTime -> m ()
- onJobRetry :: JobPayload payload => JobRead payload -> BackoffDelay -> m ()
- onJobFailedAndMovedToDLQ :: JobPayload payload => ErrorMsg -> JobRead payload -> m ()
- onJobHeartbeat :: JobPayload payload => JobRead payload -> CurrentTime -> StartTime -> m ()
- defaultObservabilityHooks :: forall (m :: Type -> Type) payload. Applicative m => ObservabilityHooks m payload
- type ClaimTime = UTCTime
- type CurrentTime = UTCTime
- type StartTime = UTCTime
- type EndTime = UTCTime
- type ErrorMsg = Text
- type BackoffDelay = NominalDiffTime
Core Job Type
data Job payload key q insertedAt Source #
A job in the queue. Parametrized over payload, primary key, queue name,
and inserted-at timestamp. See JobWrite (for insertion) and JobRead
(returned from claims/queries).
Constructors
| Job | |
Fields
| |
Instances
type JobRead payload = Job payload Int64 Text UTCTime Source #
A type alias for a job that has been read from the database.
type JobWrite payload = Job payload () () () Source #
A type alias for a job that is ready to be written to the database. It does not yet have an ID or insertion timestamp.
defaultJob :: payload -> JobWrite payload Source #
Ungrouped JobWrite with default values. For serial processing within a
group, use defaultGroupedJob.
defaultGroupedJob :: Text -> payload -> JobWrite payload Source #
Grouped JobWrite. Jobs sharing a group key are processed serially.
defaultGroupedJob "user-123" (ProcessEvent eventData)
isRollup :: Job p k q t -> Bool Source #
A rollup finalizer is any job whose parentState snapshot is present
(an empty object on insert; the merged child results before a DLQ move).
Type Constraints
type JobPayload payload = (FromJSON payload, ToJSON payload) Source #
Payloads must round-trip through JSON for PostgreSQL JSONB storage.
Deduplication
Deduplication strategy, checked on INSERT via ON CONFLICT on the dedup key.
Constructors
| IgnoreDuplicate Text | Skip if a job with this key exists ( |
| ReplaceDuplicate Text | Replace the existing job with this key ( |
Instances
| FromJSON DedupKey Source # | |||||
Defined in Arbiter.Core.Job.Types | |||||
| ToJSON DedupKey Source # | |||||
Defined in Arbiter.Core.Job.Types Methods toEncoding :: DedupKey -> Encoding toJSONList :: [DedupKey] -> Value toEncodingList :: [DedupKey] -> Encoding | |||||
| Generic DedupKey Source # | |||||
Defined in Arbiter.Core.Job.Types Associated Types
| |||||
| Show DedupKey Source # | |||||
| Eq DedupKey Source # | |||||
| type Rep DedupKey Source # | |||||
Defined in Arbiter.Core.Job.Types type Rep DedupKey = D1 ('MetaData "DedupKey" "Arbiter.Core.Job.Types" "arbiter-core-0.1.0.0-inplace" 'False) (C1 ('MetaCons "IgnoreDuplicate" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text)) :+: C1 ('MetaCons "ReplaceDuplicate" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text))) | |||||
Observability
data ObservabilityHooks (m :: Type -> Type) payload Source #
A set of callbacks invoked at key points in the job lifecycle.
Use these hooks to integrate with metrics, logging, or tracing systems. Hooks are exception-safe; any exception thrown within a hook is caught and ignored to prevent crashing the worker.
Constructors
| ObservabilityHooks | |
Fields
| |
defaultObservabilityHooks :: forall (m :: Type -> Type) payload. Applicative m => ObservabilityHooks m payload Source #
No-op hooks. Override fields to add observability:
myHooks = defaultObservabilityHooks
{ onJobSuccess = \job startTime endTime -> do
let duration = diffUTCTime endTime startTime
logInfo $ "Job " <> show (primaryKey job) <> " took " <> show duration
}
type CurrentTime = UTCTime Source #
type BackoffDelay = NominalDiffTime Source #