Software /
code /
prosody
Comparison
plugins/mod_pep.lua @ 13213:50324f66ca2a
plugins: Use integer config API with interval specification where sensible
Many of these fall into a few categories:
- util.cache size, must be >= 1
- byte or item counts that logically can't be negative
- port numbers that should be in 1..0xffff
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Mon, 17 Jul 2023 01:38:54 +0200 |
parent | 12977:74b9e05af71e |
comparison
equal
deleted
inserted
replaced
13212:3e6e98cc63e9 | 13213:50324f66ca2a |
---|---|
22 | 22 |
23 -- username -> object passed to module:add_items() | 23 -- username -> object passed to module:add_items() |
24 local pep_service_items = {}; | 24 local pep_service_items = {}; |
25 | 25 |
26 -- size of caches with full pubsub service objects | 26 -- size of caches with full pubsub service objects |
27 local service_cache_size = module:get_option_number("pep_service_cache_size", 1000); | 27 local service_cache_size = module:get_option_integer("pep_service_cache_size", 1000, 1); |
28 | 28 |
29 -- username -> util.pubsub service object | 29 -- username -> util.pubsub service object |
30 local services = cache.new(service_cache_size, function (username, _) | 30 local services = cache.new(service_cache_size, function (username, _) |
31 local item = pep_service_items[username]; | 31 local item = pep_service_items[username]; |
32 pep_service_items[username] = nil; | 32 pep_service_items[username] = nil; |
34 module:remove_item("pep-service", item); | 34 module:remove_item("pep-service", item); |
35 end | 35 end |
36 end):table(); | 36 end):table(); |
37 | 37 |
38 -- size of caches with smaller objects | 38 -- size of caches with smaller objects |
39 local info_cache_size = module:get_option_number("pep_info_cache_size", 10000); | 39 local info_cache_size = module:get_option_integer("pep_info_cache_size", 10000, 1); |
40 | 40 |
41 -- username -> recipient -> set of nodes | 41 -- username -> recipient -> set of nodes |
42 local recipients = cache.new(info_cache_size):table(); | 42 local recipients = cache.new(info_cache_size):table(); |
43 | 43 |
44 -- caps hash -> set of nodes | 44 -- caps hash -> set of nodes |
47 local host = module.host; | 47 local host = module.host; |
48 | 48 |
49 local node_config = module:open_store("pep", "map"); | 49 local node_config = module:open_store("pep", "map"); |
50 local known_nodes = module:open_store("pep"); | 50 local known_nodes = module:open_store("pep"); |
51 | 51 |
52 local max_max_items = module:get_option_number("pep_max_items", 256); | 52 local max_max_items = module:get_option_number("pep_max_items", 256, 0); |
53 | 53 |
54 local function tonumber_max_items(n) | 54 local function tonumber_max_items(n) |
55 if n == "max" then | 55 if n == "max" then |
56 return max_max_items; | 56 return max_max_items; |
57 end | 57 end |