Liking cljdoc? Tell your friends :D

sturdy.throttle.sqlite


admit-sqlclj

(admit-sql org-id rate-key bucket-ms window-start limit)

A single atomic statement that checks the rate limit and UPSERTs if allowed. Returns 1 updated row if admitted, or 0 if rejected by the WHERE clause.

A single atomic statement that checks the rate limit and UPSERTs if allowed.
Returns 1 updated row if admitted, or 0 if rejected by the WHERE clause.
sourceraw docstring

b-optsclj

source

bucket-start-msclj

(bucket-start-ms now-ms)
source

close-limiterclj

(close-limiter limiter)
source

hour-msclj

source

make-quota-limiterclj

(make-quota-limiter {:keys [db-name db-dir limit window-ms prune-every
                            batch-size profile-key]
                     :or {batch-size 500
                          profile-key :write-intensive
                          window-ms hour-ms
                          prune-every 1000}})

Creates a SQLite-backed quota limiter. Initializes the database and runs migrations. config map requires:

  • :db-dir
  • :db-name
  • :limit (number of requests per approximate window)
  • :window-ms (window size in milliseconds; defaults to one hour). The limiter rounds this up to wall-clock-aligned one-minute buckets for substantially better performance under load; boundaries can differ from an exact rolling window by less than one minute. A rate key must not be used by simultaneous limiters with different windows in one database; increasing its window has a warm-up period for previously pruned history.
  • :prune-every (approximate number of requests before running a background prune, e.g. 1000)
Creates a SQLite-backed quota limiter.
Initializes the database and runs migrations.
`config` map requires:
- :db-dir
- :db-name
- :limit (number of requests per approximate window)
- :window-ms (window size in milliseconds; defaults to one hour). The
  limiter rounds this up to wall-clock-aligned one-minute buckets for
  substantially better performance under load; boundaries can differ from
  an exact rolling window by less than one minute. A rate key must not be
  used by simultaneous limiters with different windows in one database;
  increasing its window has a warm-up period for previously pruned history.
- :prune-every (approximate number of requests before running a background prune, e.g. 1000)
sourceraw docstring

minute-msclj

source

now-msclj

(now-ms)
source

oldest-live-bucket-msclj

(oldest-live-bucket-ms now-ms)
(oldest-live-bucket-ms now-ms window-ms)
source

prune-sqlclj

(prune-sql rate-key now-ms window-ms)
source

window-bucket-countclj

(window-bucket-count window-ms)
source

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close