Software /
code /
prosody
Comparison
core/storagemanager.lua @ 5036:be33164aa97e
storagemanager: Split out driver choosing from the open() method
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sat, 28 Jul 2012 21:30:24 +0200 |
parent | 4758:b8b050e76ee1 |
child | 5037:c34fdcae6d29 |
comparison
equal
deleted
inserted
replaced
5035:874cab7b4b3e | 5036:be33164aa97e |
---|---|
56 log("error", "Failed to load storage driver plugin %s on %s: %s", driver_name, host, err); | 56 log("error", "Failed to load storage driver plugin %s on %s: %s", driver_name, host, err); |
57 end | 57 end |
58 return stores_available:get(host, driver_name); | 58 return stores_available:get(host, driver_name); |
59 end | 59 end |
60 | 60 |
61 function open(host, store, typ) | 61 function get_driver(host, store) |
62 local storage = config.get(host, "core", "storage"); | 62 local storage = config.get(host, "core", "storage"); |
63 local driver_name; | 63 local driver_name; |
64 local option_type = type(storage); | 64 local option_type = type(storage); |
65 if option_type == "string" then | 65 if option_type == "string" then |
66 driver_name = storage; | 66 driver_name = storage; |
75 if not driver then | 75 if not driver then |
76 log("warn", "Falling back to null driver for %s storage on %s", store, host); | 76 log("warn", "Falling back to null driver for %s storage on %s", store, host); |
77 driver_name = "null"; | 77 driver_name = "null"; |
78 driver = null_storage_driver; | 78 driver = null_storage_driver; |
79 end | 79 end |
80 return driver, driver_name; | |
81 end | |
80 | 82 |
83 function open(host, store, typ) | |
84 local driver, driver_name = get_driver(host, store); | |
81 local ret, err = driver:open(store, typ); | 85 local ret, err = driver:open(store, typ); |
82 if not ret then | 86 if not ret then |
83 if err == "unsupported-store" then | 87 if err == "unsupported-store" then |
84 log("debug", "Storage driver %s does not support store %s (%s), falling back to null driver", | 88 log("debug", "Storage driver %s does not support store %s (%s), falling back to null driver", |
85 driver_name, store, typ); | 89 driver_name, store, typ); |