Diff

util/pubsub.lua @ 12153:26af75c20163

util.pubsub: Fix item store resize to "max" Previously this would end up passing the "max" directly to the underlying storage.
author Kim Alvefur <zash@zash.se>
date Thu, 06 Jan 2022 01:18:35 +0100
parent 11854:b605cbd5f13b
child 12975:d10957394a3c
line wrap: on
line diff
--- a/util/pubsub.lua	Thu Jan 06 00:59:40 2022 +0100
+++ b/util/pubsub.lua	Thu Jan 06 01:18:35 2022 +0100
@@ -5,6 +5,7 @@
 local service_mt = {};
 
 local default_config = {
+	max_items = 256;
 	itemstore = function (config, _) return cache.new(config["max_items"]) end;
 	broadcaster = function () end;
 	subscriber_filter = function (subs) return subs end;
@@ -841,7 +842,11 @@
 		end
 	elseif old_config["max_items"] ~= node_obj.config["max_items"] then
 		if self.data[node] then
-			self.data[node]:resize(self.nodes[node].config["max_items"]);
+			local max_items = self.nodes[node].config["max_items"];
+			if max_items == "max" then
+				max_items = self.config.max_items;
+			end
+			self.data[node]:resize(max_items);
 		end
 	end