Exclusively use RatingServicePublish over submit URL
parent
98d81c2f2f
commit
77ddbbef3b
|
@ -50,7 +50,6 @@
|
||||||
"host": "localhost",
|
"host": "localhost",
|
||||||
"domain": ""
|
"domain": ""
|
||||||
},
|
},
|
||||||
"noResultsUrl": "",
|
|
||||||
"postRatePublish": {
|
"postRatePublish": {
|
||||||
"protocol": "amqp",
|
"protocol": "amqp",
|
||||||
"hostname": "localhost",
|
"hostname": "localhost",
|
||||||
|
|
|
@ -113,9 +113,8 @@ module.exports = AbstractClass( 'Daemon',
|
||||||
this._createDebugLog(),
|
this._createDebugLog(),
|
||||||
this._createAccessLog(),
|
this._createAccessLog(),
|
||||||
this._conf.get( 'skey' ),
|
this._conf.get( 'skey' ),
|
||||||
this._conf.get( 'services.rating.noResultsUrl' ),
|
|
||||||
this._conf.get( 'services.rating.postRatePublish' ),
|
this._conf.get( 'services.rating.postRatePublish' ),
|
||||||
] ).then( ([ debug_log, access_log, skey, no_results_url, post_rate ]) =>
|
] ).then( ([ debug_log, access_log, skey, post_rate ]) =>
|
||||||
{
|
{
|
||||||
this._debugLog = debug_log;
|
this._debugLog = debug_log;
|
||||||
this._accessLog = access_log;
|
this._accessLog = access_log;
|
||||||
|
@ -135,7 +134,6 @@ module.exports = AbstractClass( 'Daemon',
|
||||||
).then( post_rate_publish =>
|
).then( post_rate_publish =>
|
||||||
this._routers = this.getRouters(
|
this._routers = this.getRouters(
|
||||||
skey,
|
skey,
|
||||||
no_results_url,
|
|
||||||
post_rate_publish
|
post_rate_publish
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
@ -202,23 +200,18 @@ module.exports = AbstractClass( 'Daemon',
|
||||||
* Get (and initialize) controller
|
* Get (and initialize) controller
|
||||||
*
|
*
|
||||||
* The controller will only be initialized with the session key SKEY and
|
* The controller will only be initialized with the session key SKEY and
|
||||||
* all-submit notification URL NO_RESULTS_URL if they are provided,
|
* post-rate AMQP configuration if they are provided, respectively.
|
||||||
* respectively.
|
|
||||||
*
|
*
|
||||||
* @param {string=} skey session key
|
* @param {string=} skey session key
|
||||||
* @param {string=} no_results_url URL for all-submit notification
|
|
||||||
* @param {Object=} post_rate_publish configuration for post-rate messages
|
* @param {Object=} post_rate_publish configuration for post-rate messages
|
||||||
*
|
*
|
||||||
* @return {Object} controller
|
* @return {Object} controller
|
||||||
*/
|
*/
|
||||||
'protected getProgramController': function(
|
'protected getProgramController': function( skey, post_rate_publish )
|
||||||
skey, no_results_url, post_rate_publish
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
var controller = require( './controller' );
|
var controller = require( './controller' );
|
||||||
|
|
||||||
controller.rater = this._rater;
|
controller.rater = this._rater;
|
||||||
controller.no_results_url = no_results_url || controller.no_results_url;
|
|
||||||
|
|
||||||
controller.post_rate_publish =
|
controller.post_rate_publish =
|
||||||
post_rate_publish || controller.post_rate_publish;
|
post_rate_publish || controller.post_rate_publish;
|
||||||
|
@ -312,13 +305,11 @@ module.exports = AbstractClass( 'Daemon',
|
||||||
'abstract protected getEncryptionService': [],
|
'abstract protected getEncryptionService': [],
|
||||||
|
|
||||||
|
|
||||||
'protected getRouters': function(
|
'protected getRouters': function( skey, post_rate_publish )
|
||||||
skey, no_results_url, post_rate_publish
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
this.getProgramController(
|
this.getProgramController(
|
||||||
skey, no_results_url, post_rate_publish
|
skey, post_rate_publish
|
||||||
),
|
),
|
||||||
this.getScriptsController(),
|
this.getScriptsController(),
|
||||||
this.getClientErrorController(),
|
this.getClientErrorController(),
|
||||||
|
|
|
@ -113,7 +113,6 @@ var sflag = {};
|
||||||
// TODO: kluge to get liza somewhat decoupled from lovullo (rating module)
|
// TODO: kluge to get liza somewhat decoupled from lovullo (rating module)
|
||||||
exports.rater = {};
|
exports.rater = {};
|
||||||
exports.skey = "";
|
exports.skey = "";
|
||||||
exports.no_results_url = "";
|
|
||||||
exports.post_rate_publish = {};
|
exports.post_rate_publish = {};
|
||||||
|
|
||||||
|
|
||||||
|
@ -138,35 +137,8 @@ exports.init = function( logger, enc_service, conf )
|
||||||
server_cache = _createCache( server );
|
server_cache = _createCache( server );
|
||||||
server.init( server_cache, exports.rater );
|
server.init( server_cache, exports.rater );
|
||||||
|
|
||||||
// TODO: do none of this if no_results_url is provided
|
|
||||||
const createSubmitDapi = request => HttpDataApi
|
|
||||||
.use( HttpDataApiUrlData( [ 'quote_id' ] ) )
|
|
||||||
(
|
|
||||||
exports.no_results_url,
|
|
||||||
'PUT',
|
|
||||||
|
|
||||||
NodeHttpImpl
|
|
||||||
.use( SpoofedNodeHttpImpl( request ) )
|
|
||||||
(
|
|
||||||
{
|
|
||||||
http: require( 'http' ),
|
|
||||||
https: require( 'https' ),
|
|
||||||
},
|
|
||||||
require( 'url' ),
|
|
||||||
this._origin
|
|
||||||
),
|
|
||||||
''
|
|
||||||
);
|
|
||||||
|
|
||||||
// only use the submit notification if a URL was provided
|
|
||||||
const RatingServiceBase = ( exports.no_results_url )
|
|
||||||
? RatingService.use(
|
|
||||||
RatingServiceSubmitNotify( createSubmitDapi, dao )
|
|
||||||
)
|
|
||||||
: RatingService;
|
|
||||||
|
|
||||||
// TODO: temporary proof-of-concept
|
// TODO: temporary proof-of-concept
|
||||||
rating_service = RatingServiceBase.use(
|
rating_service = RatingService.use(
|
||||||
RatingServicePublish( amqplib, exports.post_rate_publish )
|
RatingServicePublish( amqplib, exports.post_rate_publish )
|
||||||
)(
|
)(
|
||||||
logger, dao, server, exports.rater
|
logger, dao, server, exports.rater
|
||||||
|
|
|
@ -30,9 +30,9 @@ var Class = require( 'easejs' ).Class;
|
||||||
*/
|
*/
|
||||||
module.exports = Class( 'RatingService',
|
module.exports = Class( 'RatingService',
|
||||||
{
|
{
|
||||||
_logger: null,
|
logger: null,
|
||||||
|
|
||||||
_dao: null,
|
dao: null,
|
||||||
|
|
||||||
_server: null,
|
_server: null,
|
||||||
|
|
||||||
|
|
|
@ -111,6 +111,8 @@ module.exports = Trait( 'RatingServicePublish' )
|
||||||
quote
|
quote
|
||||||
);
|
);
|
||||||
} );
|
} );
|
||||||
|
|
||||||
|
this.__super( request, data, actions, program, quote );
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue