arbiter-core-0.1.0.0
arbiter-core
Safe HaskellNone
LanguageGHC2024

Arbiter.Core.Sql.RateLimit

Description

RateLimit SQL templates.

Synopsis

Documentation

Source #defaultThrottleWaitSeconds :: Double

Deny-path wait (seconds) when no refill interval yields a real wait.

Source #addRateLimitTokensSQL :: SchemaName -> Text -> Text -> Double -> Query ()

Add amount to a key's bucket, clamped to [0, max], seeding an absent bucket at full. A no-op without a policy.

Source #pruneRateLimitBucketsSQL :: SchemaName -> Double -> Query ()

Delete idle buckets that have refilled to max.

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

Refill a prefix's buckets to full. The fixed-window reset, which also wakes jobs, is the HighLevel resetRateLimitBuckets.

Source #wakeThrottledJobsSQL :: SchemaName -> [TableName] -> Text -> Query Int64

Clear the rate-limit deferral on a prefix's throttled jobs. One statement over all given queue tables.

Source #wakeThrottledJobsForKeySQL :: SchemaName -> [TableName] -> Text -> Text -> Query Int64

Like wakeThrottledJobsSQL but for one key, after a top-up.

Source #refilledExpr :: Text -> Text -> Text -> Text -> Text -> Text

A bucket's lazily-refilled token count, capped at maxTokens. Arguments are SQL expressions.

Source #listRateLimitPoliciesSQL :: SchemaName -> [TableName] -> Query RateLimitPolicyView

List every policy with its default/override params and per-prefix bucket aggregates (count, min and average of lazily-refilled tokens, live throttled count over the given queue tables).

Source #rateLimitPolicyExistsSQL :: SchemaName -> Text -> Query Bool

Whether a rate-limit policy exists for a prefix.

Source #listRateLimitBucketsSQL :: SchemaName -> Text -> Int64 -> Int64 -> Query RateLimitBucketView

List a prefix's buckets with effective max and lazily-refilled fill fraction, paginated.

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

Set or clear a policy's override params. Nothing leaves a field untouched. Just v writes v (a null clears the override back to the default).