Pass full runtime object to storage and flow sub-components

This commit is contained in:
Nick O'Leary
2016-09-21 10:22:04 +01:00
parent ee45d6b48f
commit e06cadd761
6 changed files with 42 additions and 32 deletions

View File

@@ -83,7 +83,7 @@ function start() {
.then(function() {
return i18n.registerMessageCatalog("runtime",path.resolve(path.join(__dirname,"locales")),"runtime.json")
})
.then(function() { return storage.init(settings)})
.then(function() { return storage.init(runtime)})
.then(function() { return settings.load(storage)})
.then(function() {

View File

@@ -43,12 +43,12 @@ var subflowInstanceNodeMap = {};
var typeEventRegistered = false;
function init(_settings, _storage) {
function init(runtime) {
if (started) {
throw new Error("Cannot init without a stop");
}
settings = _settings;
storage = _storage;
settings = runtime.settings;
storage = runtime.storage;
started = false;
if (!typeEventRegistered) {
events.on('type-registered',function(type) {

View File

@@ -78,7 +78,7 @@ function createNode(node,def) {
function init(runtime) {
settings = runtime.settings;
credentials.init(runtime.storage);
flows.init(runtime.settings,runtime.storage);
flows.init(runtime);
registry.init(runtime);
context.init(runtime.settings);
}

View File

@@ -18,6 +18,7 @@ var when = require('when');
var Path = require('path');
var log = require("../log");
var runtime;
var storageModule;
var settingsAvailable;
var sessionsAvailable;
@@ -42,15 +43,16 @@ function is_malicious(path) {
}
var storageModuleInterface = {
init: function(settings) {
init: function(_runtime) {
runtime = _runtime;
try {
storageModule = moduleSelector(settings);
storageModule = moduleSelector(runtime.settings);
settingsAvailable = storageModule.hasOwnProperty("getSettings") && storageModule.hasOwnProperty("saveSettings");
sessionsAvailable = storageModule.hasOwnProperty("getSessions") && storageModule.hasOwnProperty("saveSessions");
} catch (e) {
return when.reject(e);
}
return storageModule.init(settings);
return storageModule.init(runtime.settings);
},
getFlows: function() {
return storageModule.getFlows();