Software /
code /
prosody
Comparison
util/pubsub.lua @ 6777:5de6b93d0190
util.*: Remove use of module() function, make all module functions local and return them in a table at the end
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sat, 21 Feb 2015 10:36:37 +0100 |
parent | 6515:c9a72c64c3e2 |
child | 6791:e813e8cf6046 |
child | 7695:56ce32cfd6d9 |
comparison
equal
deleted
inserted
replaced
6774:3965662ae091 | 6777:5de6b93d0190 |
---|---|
1 local events = require "util.events"; | 1 local events = require "util.events"; |
2 local t_remove = table.remove; | 2 local t_remove = table.remove; |
3 | |
4 module("pubsub", package.seeall); | |
5 | 3 |
6 local service = {}; | 4 local service = {}; |
7 local service_mt = { __index = service }; | 5 local service_mt = { __index = service }; |
8 | 6 |
9 local default_config = { __index = { | 7 local default_config = { __index = { |
13 } }; | 11 } }; |
14 local default_node_config = { __index = { | 12 local default_node_config = { __index = { |
15 ["pubsub#max_items"] = "20"; | 13 ["pubsub#max_items"] = "20"; |
16 } }; | 14 } }; |
17 | 15 |
18 function new(config) | 16 local function new(config) |
19 config = config or {}; | 17 config = config or {}; |
20 return setmetatable({ | 18 return setmetatable({ |
21 config = setmetatable(config, default_config); | 19 config = setmetatable(config, default_config); |
22 node_defaults = setmetatable(config.node_defaults or {}, default_node_config); | 20 node_defaults = setmetatable(config.node_defaults or {}, default_node_config); |
23 affiliations = {}; | 21 affiliations = {}; |
440 trim_items(self.data[node], node_obj.config["pubsub#max_items"]); | 438 trim_items(self.data[node], node_obj.config["pubsub#max_items"]); |
441 | 439 |
442 return true; | 440 return true; |
443 end | 441 end |
444 | 442 |
445 return _M; | 443 return { |
444 new = new; | |
445 }; |