Skip to content

Instantly share code, notes, and snippets.

View david-martin's full-sized avatar

David Martin david-martin

View GitHub Profile
  • Needs mongodb to run locally
    • e.g. docker run -p 27017:27017 --name mongo_instance_001 -d mongo:3.2 --smallfiles
  • Needs env vars set to start and connect to mongo (mimicing a SaaS MBaaS)
    • e.g. FH_SERVICE_APP_PUBLIC=true FH_MONGODB_CONN_URL=localhost:27017 npm start

Client

var async = require('async');
var asyncStringify = require('async-json');
var obj = require('./obj.json');
var start = Date.now();
for(var i=0,l=8; i<l; i++) {
JSON.stringify(obj);
}
console.log('sync stringify', Date.now() - start);
1) setUp
2) test sync with acknowledgements
info: 2017-01-26 14:38:25 [SYNC] (): stopAllDatasetSync
0 passing (432ms)
2 failing
1) setUp:
Error: invalid schema, expected mongodb
at module.exports (node_modules/mongodb/lib/url_parser.js:18:11)
diff --git a/test/test_sync-srv.js b/test/test_sync-srv.js
index 20dffec..e6ba7db 100644
--- a/test/test_sync-srv.js
+++ b/test/test_sync-srv.js
@@ -18,13 +18,19 @@ module.exports = {
protocol: 'https'
}
};
- var mongoStub = sinon.stub();
+ var mongoStub = {
{
"name": "redis-watch-test",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
diff --git a/main.go b/main.go
index 42c423b..04e9935 100644
--- a/main.go
+++ b/main.go
@@ -4,12 +4,14 @@ import (
"encoding/json"
"errors"
"fmt"
+ "github.com/codeskyblue/go-sh"
"io/ioutil"
sh-4.2$ curl http://fh-appstore:8080/sys/info/ping
(times out)
sh-4.2$ curl --resolve fh-appstore:8080:172.17.0.5 http://fh-appstore:8080/sys/info/ping
"ok"
const fs = require('fs');
function readStat(cb) {
fs.readFile("/proc/" + process.pid + "/stat", function(err, data) {
if (err) {
return cb(err);
}
# Server
redis_version:3.0.6
redis_git_sha1:00000000
redis_git_dirty:0
redis_build_id:6dcf3277028a695a
redis_mode:standalone
os:Linux 4.6.6-300.fc24.x86_64 x86_64
arch_bits:64
multiplexing_api:epoll
gcc_version:6.0.0
for (i in serverRecs) {
var serverRec = serverRecs[i];
var serverRecUid = i;
var serverRecHash = serverRec.hash;
if (clientRecs[serverRecUid]) {
// only do this if there isn't an applied or pending update of this record
if (clientRecs[serverRecUid] !== serverRecHash) {
syncUtil.doLog(dataset_id, 'verbose', 'Updating client record ' + serverRecUid + ' client hash=' + clientRecs[serverRecUid], params);
updates[serverRecUid] = serverRec;