Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
nomilous committed Aug 4, 2017
1 parent b3df009 commit 74ab145
Show file tree
Hide file tree
Showing 5 changed files with 99 additions and 5 deletions.
7 changes: 5 additions & 2 deletions README.md
Expand Up @@ -48,12 +48,15 @@ var config = {
// }
//},

// defaulted by happner-cluster to prevent description overwrites in shared db
// defaulted by happner-cluster to prevent overwrites in shared db
// where each cluster server requires unique data at certain paths
//{
// name: 'nedb-own-schema',
// settings: {},
// patterns: [
// '/mesh/schema/*'
// '/mesh/schema/*',
// '/_SYSTEM/_NETWORK/_SETTINGS/NAME',
// '/_SYSTEM/_SECURITY/_SETTINGS/KEYPAIR'
// ]
//}
]
Expand Down
6 changes: 5 additions & 1 deletion RELEASES.md
Expand Up @@ -9,7 +9,7 @@
- onward release of happn-cluster
- onward release of happner-2
- onward release of happner-client

1.4.2 2017-04-19
----------------
- onward release of happner-2
Expand All @@ -18,3 +18,7 @@
----------------
- updated happner-2 to 3.0.0
- start happn-cluster proxy (through which client access cluster) after component startMethods are run

2.0.1 2017-08-04
----------------
- add `/_SYSTEM/_NETWORK/_SETTINGS/NAME` and `/_SYSTEM/_SECURITY/_SETTINGS/KEYPAIR` to local storage (nedb, non-shared)
15 changes: 14 additions & 1 deletion lib/nedb.js
Expand Up @@ -6,7 +6,18 @@ module.exports.gotConfig = function (config) {
var present = false;
config.happn.services.data.config.datastores.forEach(function (ds) {
if (!ds.patterns) return;

// use /nesh/schema to spot the nedb datastore
if (ds.patterns.indexOf('/mesh/schema/*') >= 0) {

if (ds.patterns.indexOf('/_SYSTEM/_NETWORK/_SETTINGS/NAME') < 0) {
ds.patterns.push('/_SYSTEM/_NETWORK/_SETTINGS/NAME');
}

if (ds.patterns.indexOf('/_SYSTEM/_SECURITY/_SETTINGS/KEYPAIR') < 0) {
ds.patterns.push('/_SYSTEM/_SECURITY/_SETTINGS/KEYPAIR');
}

present = true;
}
});
Expand All @@ -22,7 +33,9 @@ module.exports.addConfig = function (config) {
name: 'nedb-own-schema',
settings: {},
patterns: [
'/mesh/schema/*'
'/mesh/schema/*',
'/_SYSTEM/_NETWORK/_SETTINGS/NAME',
'/_SYSTEM/_SECURITY/_SETTINGS/KEYPAIR'
]
});
};
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "happner-cluster",
"version": "2.0.0",
"version": "2.0.1",
"description": "Extends happner with clustering capabilities",
"main": "index.js",
"scripts": {
Expand Down
74 changes: 74 additions & 0 deletions test/unit/01-unit-cluster-create.js
Expand Up @@ -85,4 +85,78 @@ describe('01 - unit - cluster create', function () {
HappnerCluster.create({});
});

it('assigns private nedb datastore config if missing', function (done) {
Happner.create = function (config) {
expect(config.happn.services.data.config.datastores).to.eql([{
name: 'nedb-own-schema',
settings: {},
patterns: ['/mesh/schema/*',
'/_SYSTEM/_NETWORK/_SETTINGS/NAME',
'/_SYSTEM/_SECURITY/_SETTINGS/KEYPAIR'
]
}]);
return Promise.resolve({
_mesh: {
happn: {
server: {
services: {
proxy: {
start: function () {
done();
}
}
}
}
}
}
});
};

HappnerCluster.create({});
});

it('it ammends private nedb datastore config if missing entries', function (done) {
Happner.create = function (config) {
expect(config.happn.services.data.config.datastores).to.eql([{
name: 'alternative-name',
settings: {},
patterns: ['/mesh/schema/*',
'/_SYSTEM/_NETWORK/_SETTINGS/NAME',
'/_SYSTEM/_SECURITY/_SETTINGS/KEYPAIR'
]
}]);
return Promise.resolve({
_mesh: {
happn: {
server: {
services: {
proxy: {
start: function () {
done();
}
}
}
}
}
}
});
};

HappnerCluster.create({
happn: {
services: {
data: {
config: {
datastores: [{
name: 'alternative-name',
settings: {},
patterns: ['/mesh/schema/*']
}]
}
}
}
}
})
})

});

0 comments on commit 74ab145

Please sign in to comment.