Skip to content

Commit

Permalink
#205 add autopersist to configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
Zsolt Lattmann committed Mar 11, 2015
1 parent f33cf3f commit 84a00f0
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 15 deletions.
1 change: 1 addition & 0 deletions config/config.global.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ var config = {
},

storage: {
autoPersist: true, // core setting
cache: 2000,
keyType: 'plainSHA1', // 'rand160Bits', 'ZSSHA', 'plainSHA1',
timeout: 10000,
Expand Down
19 changes: 10 additions & 9 deletions src/client/js/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ define([

function getNewCore(project, gmeConfig) {
//return new NullPointerCore(new DescriptorCore(new SetCore(new GuidCore(new Core(project)))));
var options = {autopersist: true, usertype: 'nodejs', globConf: gmeConfig};
// FIXME: why usertype is nodejs when it is running from the browser?
var options = {usertype: 'nodejs', globConf: gmeConfig};
return Core(project, options);
}

Expand Down Expand Up @@ -211,10 +212,10 @@ define([
//default configuration
//FIXME: Are these gme options or not??
_configuration = _configuration || {};
_configuration.autoreconnect = _configuration.autoreconnect === null || _configuration.autoreconnect === undefined ? true : _configuration.autoreconnect;
_configuration.reconndelay = _configuration.reconndelay || 1000;
_configuration.reconnamount = _configuration.reconnamount || 1000;
_configuration.autostart = _configuration.autostart === null || _configuration.autostart === undefined ? false : _configuration.autostart;
_configuration.autoreconnect = true;
_configuration.reconndelay = 1000;
_configuration.reconnamount = 1000;
_configuration.autostart = false;

//if( typeof GME !== 'undefined'){
// GME.config = GME.config || {};
Expand Down Expand Up @@ -274,7 +275,7 @@ define([
protocolStr = gmeConfig.server.https.enable ? 'https' : 'http';

storageOptions.type = 'node';
storageOptions.host = protocolStr + '://localhost';
storageOptions.host = protocolStr + '://127.0.0.1';
storageOptions.user = 'TEST';
} else {
storageOptions.user = getUserId();
Expand Down Expand Up @@ -740,9 +741,9 @@ define([
_networkStatus = "";
var running = true;
//FIXME: Are these gme options or not??
var autoReconnect = _configuration.autoreconnect ? true : false;
var reConnDelay = _configuration.reconndelay || 1000;
var reConnAmount = _configuration.reconnamount || 1000;
var autoReconnect = _configuration.autoreconnect;
var reConnDelay = _configuration.reconndelay;
var reConnAmount = _configuration.reconnamount;
var reconnecting = function () {
var counter = 0;
var timerId = setInterval(function () {
Expand Down
2 changes: 1 addition & 1 deletion src/common/core/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ define([

function core(storage,options){
options = options || {};
options.usertype = options.usertype || 'nodejs';
options.usertype = options.usertype || 'nodejs'; // FIXME: why this is nodejs???

var coreCon = new TreeLoader(new CoreDiff(new MetaCore(new Constraint(new Guid(new Set(new NullPtr(new Type(new NullPtr(new CoreRel(new CoreTree(storage, options)))))))))));

Expand Down
3 changes: 1 addition & 2 deletions src/common/core/coretree.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ define([ "util/assert", "util/key", "core/future", "core/tasync", 'util/canon' ]
var MAX_AGE = 3; // MAGIC NUMBER
var MAX_TICKS = 2000; // MAGIC NUMBER
var MAX_MUTATE = 30000; // MAGIC NUMBER
var autopersist = (options && options.autopersist) || false;

var ID_NAME = storage.ID_NAME;
var EMPTY_DATA = {};
Expand Down Expand Up @@ -458,7 +457,7 @@ define([ "util/assert", "util/key", "core/future", "core/tasync", 'util/canon' ]
}

// TODO: infinite cycle if MAX_MUTATE is smaller than depth!
if (autopersist && ++mutateCount > MAX_MUTATE) {
if (gmeConfig.storage.autoPersist && ++mutateCount > MAX_MUTATE) {
mutateCount = 0;

for (var i = 0; i < roots.length; ++i) {
Expand Down
2 changes: 1 addition & 1 deletion src/server/worker/simpleworker.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ requirejs(['worker/constants',
return callback("" + err);
}

var core = new Core(project),
var core = new Core(project, {globConf: gmeConfig}),
root = core.createNode({parent: null, base: null});
Serialization.import(core, root, jsonProject, function (err) {
if (err) {
Expand Down
2 changes: 1 addition & 1 deletion test/common/core/constraintcore.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ describe('constraint core', function () {
return;
}
project = p;
core = new testFixture.WebGME.core(project,{usertype:'tasync'});
core = new testFixture.WebGME.core(project,{usertype:'tasync', globConf: gmeConfig});
root = core.createNode();
base = core.createNode({parent: root});
core.setAttribute(base, 'name', 'base');
Expand Down
2 changes: 1 addition & 1 deletion test/common/core/metacore.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ describe('meta core', function () {
return;
}
project = p;
core = new testFixture.WebGME.core(project);
core = new testFixture.WebGME.core(project, {globConf: gmeConfig});
root = core.createNode();
base = core.createNode({parent: root});
core.setAttribute(base, 'name', 'base');
Expand Down

0 comments on commit 84a00f0

Please sign in to comment.