Software /
code /
prosody
Annotate
plugins/mod_storage_internal.lua @ 5442:e66973c81e89
Merge 0.9->trunk
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Mon, 08 Apr 2013 12:08:34 +0100 |
parent | 5153:688aeac0012a |
child | 6283:7cf6d3a2c855 |
rev | line source |
---|---|
4085
7699cef04740
storagemanager, mod_storage_internal: Split out default driver to mod_storage_internal, and greatly simplify storagemanager's error handling and fallback code
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1 local datamanager = require "core.storagemanager".olddm; |
7699cef04740
storagemanager, mod_storage_internal: Split out default driver to mod_storage_internal, and greatly simplify storagemanager's error handling and fallback code
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2 |
7699cef04740
storagemanager, mod_storage_internal: Split out default driver to mod_storage_internal, and greatly simplify storagemanager's error handling and fallback code
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3 local host = module.host; |
7699cef04740
storagemanager, mod_storage_internal: Split out default driver to mod_storage_internal, and greatly simplify storagemanager's error handling and fallback code
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4 |
5122
b41c33dc7c36
mod_storage_*: Don't explicitly set driver name, to ease copying/renaming modules.
Waqas Hussain <waqas20@gmail.com>
parents:
5121
diff
changeset
|
5 local driver = {}; |
4085
7699cef04740
storagemanager, mod_storage_internal: Split out default driver to mod_storage_internal, and greatly simplify storagemanager's error handling and fallback code
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6 local driver_mt = { __index = driver }; |
7699cef04740
storagemanager, mod_storage_internal: Split out default driver to mod_storage_internal, and greatly simplify storagemanager's error handling and fallback code
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7 |
5153
688aeac0012a
mod_storage_internal, datamanager: Add support for iterating over users with data in a store
Kim Alvefur <zash@zash.se>
parents:
5133
diff
changeset
|
8 function driver:open(store, typ) |
688aeac0012a
mod_storage_internal, datamanager: Add support for iterating over users with data in a store
Kim Alvefur <zash@zash.se>
parents:
5133
diff
changeset
|
9 return setmetatable({ store = store, type = typ }, driver_mt); |
4085
7699cef04740
storagemanager, mod_storage_internal: Split out default driver to mod_storage_internal, and greatly simplify storagemanager's error handling and fallback code
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
10 end |
7699cef04740
storagemanager, mod_storage_internal: Split out default driver to mod_storage_internal, and greatly simplify storagemanager's error handling and fallback code
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
11 function driver:get(user) |
7699cef04740
storagemanager, mod_storage_internal: Split out default driver to mod_storage_internal, and greatly simplify storagemanager's error handling and fallback code
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
12 return datamanager.load(user, host, self.store); |
7699cef04740
storagemanager, mod_storage_internal: Split out default driver to mod_storage_internal, and greatly simplify storagemanager's error handling and fallback code
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
13 end |
7699cef04740
storagemanager, mod_storage_internal: Split out default driver to mod_storage_internal, and greatly simplify storagemanager's error handling and fallback code
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
14 |
7699cef04740
storagemanager, mod_storage_internal: Split out default driver to mod_storage_internal, and greatly simplify storagemanager's error handling and fallback code
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
15 function driver:set(user, data) |
7699cef04740
storagemanager, mod_storage_internal: Split out default driver to mod_storage_internal, and greatly simplify storagemanager's error handling and fallback code
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
16 return datamanager.store(user, host, self.store, data); |
7699cef04740
storagemanager, mod_storage_internal: Split out default driver to mod_storage_internal, and greatly simplify storagemanager's error handling and fallback code
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
17 end |
7699cef04740
storagemanager, mod_storage_internal: Split out default driver to mod_storage_internal, and greatly simplify storagemanager's error handling and fallback code
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
18 |
5130
051d352ed03c
storagemanager, datamanager, mod_storage_{internal,sql}: Replace list_stores() with an iterator version
Kim Alvefur <zash@zash.se>
parents:
5039
diff
changeset
|
19 function driver:stores(username) |
051d352ed03c
storagemanager, datamanager, mod_storage_{internal,sql}: Replace list_stores() with an iterator version
Kim Alvefur <zash@zash.se>
parents:
5039
diff
changeset
|
20 return datamanager.stores(username, host); |
5033
c64b5081bfa8
mod_storage_internal: Add method for listing stores
Kim Alvefur <zash@zash.se>
parents:
4085
diff
changeset
|
21 end |
c64b5081bfa8
mod_storage_internal: Add method for listing stores
Kim Alvefur <zash@zash.se>
parents:
4085
diff
changeset
|
22 |
5153
688aeac0012a
mod_storage_internal, datamanager: Add support for iterating over users with data in a store
Kim Alvefur <zash@zash.se>
parents:
5133
diff
changeset
|
23 function driver:users() |
688aeac0012a
mod_storage_internal, datamanager: Add support for iterating over users with data in a store
Kim Alvefur <zash@zash.se>
parents:
5133
diff
changeset
|
24 return datamanager.users(host, self.store, self.type); |
688aeac0012a
mod_storage_internal, datamanager: Add support for iterating over users with data in a store
Kim Alvefur <zash@zash.se>
parents:
5133
diff
changeset
|
25 end |
688aeac0012a
mod_storage_internal, datamanager: Add support for iterating over users with data in a store
Kim Alvefur <zash@zash.se>
parents:
5133
diff
changeset
|
26 |
5039
656ce68c4781
mod_storage_internal: Add method for removing all data belonging to a user
Kim Alvefur <zash@zash.se>
parents:
5033
diff
changeset
|
27 function driver:purge(user) |
656ce68c4781
mod_storage_internal: Add method for removing all data belonging to a user
Kim Alvefur <zash@zash.se>
parents:
5033
diff
changeset
|
28 return datamanager.purge(user, host); |
656ce68c4781
mod_storage_internal: Add method for removing all data belonging to a user
Kim Alvefur <zash@zash.se>
parents:
5033
diff
changeset
|
29 end |
656ce68c4781
mod_storage_internal: Add method for removing all data belonging to a user
Kim Alvefur <zash@zash.se>
parents:
5033
diff
changeset
|
30 |
5121
b5a5643f8572
core.storagemanager, mod_storage_*: "data-driver" -> "storage-provider", to allow using module:provides().
Waqas Hussain <waqas20@gmail.com>
parents:
5039
diff
changeset
|
31 module:provides("storage", driver); |