arbiter-core-0.1.0.0
arbiter-core
Safe HaskellNone
LanguageGHC2024

Arbiter.Core.Sql.Gates

Description

Internal to the arbiter packages. Not covered by the PVP.

Gates SQL templates.

Synopsis

Documentation

ensureGateRowSQL :: SchemaName -> Text -> Query ()Source #

Idempotently create the gate row for a task.

checkGateSQL :: SchemaName -> Text -> Double -> Query BoolSource #

Read-only pre-transaction check. TRUE when last_run_at is older than the interval.

tryClaimGateSQL :: SchemaName -> Text -> Double -> Query (Maybe Value)Source #

Claim the gate row when the interval elapsed and no concurrent transaction holds it. Returns the state the last run left. One row back means claimed.

claimOrReadGateSQL :: SchemaName -> Text -> Double -> Double -> Query (Maybe UTCTime, Maybe UTCTime, Maybe Value, Maybe Double)Source #

Claim the gate, or read what the last winner published. NULL timestamps mean lost.

releaseGateSQL :: SchemaName -> Text -> UTCTime -> UTCTime -> Query ()Source #

Put a claim's watermark back, for a winner whose work never published. Scoped to the value that claim wrote.

gateNameDigestSQL :: Text -> Query TextSource #

An md5 digest, for a gate name too long to be a key itself.

bumpGateSQL :: SchemaName -> Text -> Query ()Source #

Bump last_run_at to NOW() inside the claim transaction.

bumpGateStateSQL :: SchemaName -> Text -> Value -> Query ()Source #

bumpGateSQL carrying the state the task resumes from, written under the claim.

setGateMetadataSQL :: SchemaName -> Value -> UTCTime -> Text -> Query ()Source #

Publish what the task computed, stamped with the claim the work started from. The gate's interval restarts from the publish.