arbiter-core-0.1.0.0
arbiter-core
Safe HaskellNone
LanguageGHC2024

Arbiter.Core.Sql.RateLimit

Description

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

Rate-limit SQL templates.

Synopsis

Documentation

defaultThrottleWaitSeconds :: DoubleSource #

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

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

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

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

Delete idle buckets that have refilled to max.

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

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

wakeThrottledJobsSQL :: SchemaName -> [TableName] -> Text -> Query Int64Source #

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

wakeThrottledJobsForKeySQL :: SchemaName -> [TableName] -> Text -> Text -> Query Int64Source #

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

refilledExpr :: Text -> Text -> Text -> Text -> Text -> TextSource #

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

refilledBucketTokens :: TextSource #

The lazily-refilled token count of the bucket at alias bucket under the policy at alias policy.

rateLimitPoliciesSQL :: SchemaName -> [TableName] -> Maybe Text -> Query RateLimitPolicyViewSource #

The policy views, every policy or the one a prefix names.

rateLimitPolicyExistsSQL :: SchemaName -> Text -> Query BoolSource #

Whether a rate-limit policy exists for a prefix.

listRateLimitBucketsSQL :: SchemaName -> Text -> Int64 -> Int64 -> Query RateLimitBucketViewSource #

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

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

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).