aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2011-01-06 13:56:39 +0000
committerMatthew Wild <mwild1@gmail.com>2011-01-06 13:56:39 +0000
commit267fa68a568821de651999d666e43e1933bd21a5 (patch)
tree15ba184de25eb3c3955f9c53c03e95d015db630e
parent43db72be07987925dce775f19bf944cdea30126d (diff)
downloadprosody-267fa68a568821de651999d666e43e1933bd21a5.tar.gz
prosody-267fa68a568821de651999d666e43e1933bd21a5.zip
storagemanager: Add new "null" provider to get used when loading a driver or opening a store fails, instead of falling back to the default driver
-rw-r--r--core/storagemanager.lua24
1 files changed, 20 insertions, 4 deletions
diff --git a/core/storagemanager.lua b/core/storagemanager.lua
index 49987112..9f97e565 100644
--- a/core/storagemanager.lua
+++ b/core/storagemanager.lua
@@ -15,6 +15,19 @@ local prosody = prosody;
module("storagemanager")
+local null_storage_method = function () return false, "no data storage active"; end
+local null_storage_driver = setmetatable(
+ {
+ name = "null",
+ open = function (self) return self; end
+ }, {
+ __index = function (self, method)
+ return null_storage_method;
+ end
+ }
+);
+
+--TODO: Move default driver to mod_auth_internal
local default_driver_mt = { name = "internal" };
default_driver_mt.__index = default_driver_mt;
function default_driver_mt:open(store)
@@ -73,10 +86,13 @@ function open(host, store, typ)
if not driver then
if driver_name or (type(storage) == "string"
or type(storage) == "table" and storage[store]) then
- log("warn", "Falling back to default driver for %s storage on %s", store, host);
+ log("warn", "Falling back to null driver for %s storage on %s", store, host);
+ driver_name = "null";
+ driver = null_storage_driver;
+ else
+ driver_name = "internal";
+ driver = load_driver(host, driver_name);
end
- driver_name = "internal";
- driver = load_driver(host, driver_name);
end
end
@@ -85,7 +101,7 @@ function open(host, store, typ)
if err == "unsupported-store" then
log("debug", "Storage driver %s does not support store %s (%s), falling back to internal driver",
driver_name, store, typ);
- ret = setmetatable({ host = host, store = store }, default_driver_mt); -- default to default driver
+ ret = null_storage_driver;
err = nil;
end
end