Add config key for selecting storage mode

This commit is contained in:
calzoneman 2015-09-30 21:55:45 -07:00
parent e91635b6f9
commit 9c5ada6134
3 changed files with 25 additions and 1 deletions

View file

@ -1,7 +1,8 @@
import { FileStore } from './filestore';
import { DatabaseStore } from './dbstore';
import Config from '../config';
const CHANNEL_STORE = new FileStore();
const CHANNEL_STORE = loadChannelStore();
export function load(channelName) {
return CHANNEL_STORE.load(channelName);
@ -10,3 +11,13 @@ export function load(channelName) {
export function save(channelName, data) {
return CHANNEL_STORE.save(channelName, data);
}
function loadChannelStore() {
switch (Config.get('channel-storage.type')) {
case 'database':
return new DatabaseStore();
case 'file':
default:
return new FileStore();
}
}

View file

@ -110,6 +110,9 @@ var defaults = {
"user": "nobody",
"timeout": 15
},
"channel-storage": {
type: "file"
}
};
/**