-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #447 from Optum/master
R0.9.0
- Loading branch information
Showing
48 changed files
with
3,567 additions
and
3,298 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,4 +11,5 @@ specs | |
.nyc_output | ||
*.DS_store | ||
public/js/bower_components | ||
public/fusepartials | ||
.vscode/settings.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
const System = require('../models/common/System'); | ||
const MQService = require('../models/mq/MQService'); | ||
const virtual = require('../routes/virtual'); | ||
const debug = require('debug')('default'); | ||
|
||
function registerAllMQServices() { | ||
System.find({}, function(err, systems) { | ||
if (err) { | ||
debug('Error registering MQ services: ' + err); | ||
return; | ||
} | ||
|
||
systems.forEach(function(system) { | ||
registerMQServicesInSystem(system); | ||
}); | ||
}); | ||
} | ||
|
||
function registerMQServicesInSystem(sut, exclude) { | ||
MQService.find({ 'sut.name' : sut.name }, function(err, mqservices) { | ||
if (err) { | ||
debug('Error registering MQ services: ' + err); | ||
return; | ||
} | ||
|
||
mqservices.forEach(function(mqservice) { | ||
if (!deepEquals(mqservice, exclude)) | ||
registerMQService(mqservice, sut); | ||
}); | ||
}); | ||
} | ||
|
||
function registerMQService(mqserv, sut) { | ||
if (!sut) { | ||
System.findOne({ 'name' : mqserv.sut.name }, function(err, system) { | ||
if (err) { | ||
debug('Error registering MQ service: ' + err); | ||
return; | ||
} | ||
|
||
register(mqserv, system); | ||
}); | ||
} | ||
else { | ||
register(mqserv, sut); | ||
} | ||
|
||
function register(mqservice, system) { | ||
if (!mqservice.running || !system || !system.mqInfo) { | ||
return; | ||
} | ||
|
||
mqservice.basePath = `/mq/${system.mqInfo.manager}/${system.mqInfo.reqQueue}`; | ||
|
||
mqservice.rrpairs.forEach(function(rrpair){ | ||
rrpair.verb = 'POST'; | ||
if (!rrpair.payloadType) rrpair.payloadType = 'XML'; | ||
|
||
virtual.registerRRPair(mqservice, rrpair); | ||
}); | ||
} | ||
} | ||
|
||
function deregisterMQService(mqserv) { | ||
System.findOne({ name: mqserv.sut.name }, function(err, sut) { | ||
if (err) { | ||
debug('Error deregistering MQ services: ' + err); | ||
return; | ||
} | ||
|
||
if (!sut) { | ||
return; | ||
} | ||
|
||
deregisterMQServicesByInfo(sut.mqInfo, reregister); | ||
|
||
function reregister(mqinfo) { | ||
let q = { | ||
'$and': [{ | ||
'mqInfo.manager': mqinfo.manager | ||
}, { | ||
'mqInfo.reqQueue': mqinfo.reqQueue | ||
}] | ||
} | ||
|
||
System.find(q, function(err, systems) { | ||
if (err) { | ||
debug('Error reregistering MQ services: ' + err); | ||
return; | ||
} | ||
|
||
systems.forEach(function(system) { | ||
registerMQServicesInSystem(system, mqserv); | ||
}); | ||
}); | ||
} | ||
}); | ||
} | ||
|
||
function deregisterMQServicesByInfo(mqinfo, cb) { | ||
if (!mqinfo) { | ||
return; | ||
} | ||
|
||
let mqserv = { | ||
basePath: `/mq/${mqinfo.manager}/${mqinfo.reqQueue}`, | ||
rrpairs: [{}] | ||
}; | ||
virtual.deregisterService(mqserv); | ||
|
||
setTimeout(function() { | ||
cb(mqinfo); | ||
}, 300); | ||
} | ||
|
||
module.exports = { | ||
registerMQService: registerMQService, | ||
deregisterMQService: deregisterMQService, | ||
registerAllMQServices: registerAllMQServices | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
const request = require('request'); | ||
const debug = require('debug')('default'); | ||
const mockiatoJmsUri = process.env.MOCKIATO_JMS_URI; | ||
|
||
function getMQInfo(req, res) { | ||
if (!mockiatoJmsUri) { | ||
debug('MOCKIATO_JMS_URI not set'); | ||
handleError('Could not retrieve MQ info', res, 500); | ||
return; | ||
} | ||
|
||
request(mockiatoJmsUri + '/env', function(err, resp, body) { | ||
if (err) { | ||
debug(err); | ||
handleError('Could not retrieve MQ info', res, 500); | ||
return; | ||
} | ||
|
||
let data = parseInfo(body); | ||
|
||
res.json(data); | ||
}); | ||
} | ||
|
||
function parseInfo(body) { | ||
let obj = JSON.parse(body); | ||
let query = process.env.MOCKIATO_JMS_QUERY; | ||
let info = unflattenObject(obj[query]); | ||
|
||
if (!info || !info.mockiato) { | ||
return { msg: 'Could not retrieve MQ info' }; | ||
} | ||
let final = info.mockiato.mq; | ||
|
||
final.defaults = { | ||
manager: process.env.DEFAULT_QUEUE_MANAGER, | ||
reqQueue: process.env.DEFAULT_REQUEST_QUEUE | ||
}; | ||
|
||
return final; | ||
} | ||
|
||
module.exports = { | ||
getMQInfo: getMQInfo | ||
}; |
Oops, something went wrong.