| Safe Haskell | None |
|---|---|
| Language | GHC2024 |
Arbiter.Core.RateLimit.Schema
Contents
Description
Conversion of declared Policy values to upsertable rows, plus DDL for the
policies table, bucket table, and job columns. No database execution here.
Synopsis
- data PolicyRow = PolicyRow {}
- toPolicyRow :: Policy -> PolicyRow
- arbiterRateLimitPoliciesTable :: SchemaName -> Text
- arbiterRateLimitPoliciesTableName :: Text
- arbiterRateLimitsTable :: SchemaName -> Text
- arbiterRateLimitsTableName :: Text
- createRateLimitPoliciesTableSQL :: SchemaName -> Text
- createRateLimitsTableSQL :: SchemaName -> Text
- alterRateLimitsDurabilitySQL :: Durability -> SchemaName -> Text
- upsertPolicyRowSQL :: SchemaName -> PolicyRow -> Text
- addRateLimitColumnsSQL :: SchemaName -> TableName -> Text
- addRateLimitCostColumnSQL :: SchemaName -> TableName -> Text
- createThrottledIndexSQL :: SchemaName -> TableName -> Text
- createRateLimitBucketTriggerFunctionsSQL :: SchemaName -> TableName -> Text
- createRateLimitBucketTriggersSQL :: SchemaName -> TableName -> Text
- bucketSeedInsert :: Text -> Text -> Text -> Text -> Text
Policy rows
A token-bucket policy as upsertable row fields.
Constructors
| PolicyRow | |
Source #toPolicyRow :: Policy -> PolicyRow
A policy in its stored form.
Table name helpers
Source #arbiterRateLimitPoliciesTable :: SchemaName -> Text
Qualified name of the app-global policies table.
Source #arbiterRateLimitPoliciesTableName :: Text
Bare name of the policies table, for catalog lookups by relname.
Source #arbiterRateLimitsTable :: SchemaName -> Text
Qualified name of the single bucket table. Its WAL durability is a table-level property reconciled by the migration.
Source #arbiterRateLimitsTableName :: Text
Bare (unqualified) name of the bucket table, for catalog lookups by relname.
DDL
Source #createRateLimitPoliciesTableSQL :: SchemaName -> Text
DDL for the policies table. default_* is migration-owned. override_* is
management-owned. The effective params are COALESCE(override, default).
Source #createRateLimitsTableSQL :: SchemaName -> Text
DDL for the bucket table, always created UNLOGGED.
Source #alterRateLimitsDurabilitySQL :: Durability -> SchemaName -> Text
Converge the bucket table's WAL persistence to a durability. Rewrites the
table under ACCESS EXCLUSIVE. Callers issue it when the durability differs
from the current state.
Source #upsertPolicyRowSQL :: SchemaName -> PolicyRow -> Text
Upsert a policy's default_* params. Any operator override_* is left untouched.
Source #addRateLimitColumnsSQL :: SchemaName -> TableName -> Text
Migration adding the rate-limit columns to a queue's job and DLQ tables. All
nullable. throttled_until (job table only) marks a throttle-deferred grouped
head in-flight. Its group stays stalled and spends no attempt.
Source #addRateLimitCostColumnSQL :: SchemaName -> TableName -> Text
Add the per-job token cost column to a queue's job and DLQ tables. Defaulted to a unit cost. Existing rows backfill to it. The DLQ stores it and a retried job retains its cost.
Source #createThrottledIndexSQL :: SchemaName -> TableName -> Text
Index backing the throttle wake and per-prefix count, in its own migration. The
prefix leads and rate_limit_key trails.
Source #createRateLimitBucketTriggerFunctionsSQL :: SchemaName -> TableName -> Text
Statement-level triggers that ensure a full token bucket row exists for every rate-limited job's key whose prefix has a policy. Tokens are spent at claim and refill over time. There is no delete trigger. Key creation or a dedup-replace key move seeds a row.
Source #createRateLimitBucketTriggersSQL :: SchemaName -> TableName -> Text
The statement-level AFTER INSERT and AFTER UPDATE triggers backing
createRateLimitBucketTriggerFunctionsSQL. There is no delete trigger.