1
0
Fork 0

Exclusively use RatingServicePublish over submit URL

master
Mike Gerwitz 2019-03-26 11:01:16 -04:00
parent 98d81c2f2f
commit 77ddbbef3b
5 changed files with 11 additions and 47 deletions

View File

@ -50,7 +50,6 @@
"host": "localhost",
"domain": ""
},
"noResultsUrl": "",
"postRatePublish": {
"protocol": "amqp",
"hostname": "localhost",

View File

@ -113,9 +113,8 @@ module.exports = AbstractClass( 'Daemon',
this._createDebugLog(),
this._createAccessLog(),
this._conf.get( 'skey' ),
this._conf.get( 'services.rating.noResultsUrl' ),
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._accessLog = access_log;
@ -135,7 +134,6 @@ module.exports = AbstractClass( 'Daemon',
).then( post_rate_publish =>
this._routers = this.getRouters(
skey,
no_results_url,
post_rate_publish
)
);
@ -202,23 +200,18 @@ module.exports = AbstractClass( 'Daemon',
* Get (and initialize) controller
*
* The controller will only be initialized with the session key SKEY and
* all-submit notification URL NO_RESULTS_URL if they are provided,
* respectively.
* post-rate AMQP configuration if they are provided, respectively.
*
* @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
*
* @return {Object} controller
*/
'protected getProgramController': function(
skey, no_results_url, post_rate_publish
)
'protected getProgramController': function( skey, post_rate_publish )
{
var controller = require( './controller' );
controller.rater = this._rater;
controller.no_results_url = no_results_url || controller.no_results_url;
controller.rater = this._rater;
controller.post_rate_publish =
post_rate_publish || controller.post_rate_publish;
@ -312,13 +305,11 @@ module.exports = AbstractClass( 'Daemon',
'abstract protected getEncryptionService': [],
'protected getRouters': function(
skey, no_results_url, post_rate_publish
)
'protected getRouters': function( skey, post_rate_publish )
{
return [
this.getProgramController(
skey, no_results_url, post_rate_publish
skey, post_rate_publish
),
this.getScriptsController(),
this.getClientErrorController(),

View File

@ -113,7 +113,6 @@ var sflag = {};
// TODO: kluge to get liza somewhat decoupled from lovullo (rating module)
exports.rater = {};
exports.skey = "";
exports.no_results_url = "";
exports.post_rate_publish = {};
@ -138,35 +137,8 @@ exports.init = function( logger, enc_service, conf )
server_cache = _createCache( server );
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
rating_service = RatingServiceBase.use(
rating_service = RatingService.use(
RatingServicePublish( amqplib, exports.post_rate_publish )
)(
logger, dao, server, exports.rater

View File

@ -30,9 +30,9 @@ var Class = require( 'easejs' ).Class;
*/
module.exports = Class( 'RatingService',
{
_logger: null,
logger: null,
_dao: null,
dao: null,
_server: null,

View File

@ -111,6 +111,8 @@ module.exports = Trait( 'RatingServicePublish' )
quote
);
} );
this.__super( request, data, actions, program, quote );
},