Mercurial > prosody-hg
comparison plugins/mod_limits.lua @ 13209:c8d949cf6b09
plugins: Switch to :get_option_period() for time range options
Improves readability ("1 day" vs 86400) and centralizes validation.
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Sun, 16 Jul 2023 20:49:33 +0200 |
| parents | 74b9e05af71e |
| children | f65302ea37b0 |
comparison
equal
deleted
inserted
replaced
| 13208:a7c6ea1c5308 | 13209:c8d949cf6b09 |
|---|---|
| 5 local throttle = require "prosody.util.throttle"; | 5 local throttle = require "prosody.util.throttle"; |
| 6 local timer = require "prosody.util.timer"; | 6 local timer = require "prosody.util.timer"; |
| 7 local ceil = math.ceil; | 7 local ceil = math.ceil; |
| 8 | 8 |
| 9 local limits_cfg = module:get_option("limits", {}); | 9 local limits_cfg = module:get_option("limits", {}); |
| 10 local limits_resolution = module:get_option_number("limits_resolution", 1); | 10 local limits_resolution = module:get_option_period("limits_resolution", 1); |
| 11 | 11 |
| 12 local default_bytes_per_second = 3000; | 12 local default_bytes_per_second = 3000; |
| 13 local default_burst = 2; | 13 local default_burst = 2; |
| 14 | 14 |
| 15 local rate_units = { b = 1, k = 3, m = 6, g = 9, t = 12 } -- Plan for the future. | 15 local rate_units = { b = 1, k = 3, m = 6, g = 9, t = 12 } -- Plan for the future. |
