Example #1
0
var enable = module.exports.enable = function(callback) {
    callback = callback || function(err) { /* error is logged within the implementation */ };
    registerProcessor('oae-image-processor', 'file', PreviewConstants.TYPES.IMAGE, 10, PreviewImages.generatePreviews);
    registerProcessor('oae-office-processor', 'file', PreviewConstants.TYPES.OFFICE, 10, PreviewOffice.generatePreviews);
    registerProcessor('oae-pdf-processor', 'file', PreviewConstants.TYPES.PDF, 10, PreviewPDF.generatePreviews);

    // Set up the message queue and start listenening for preview tasks.
    var options = {
        'subscribe': {
            'prefetchCount': 1
        }
    };

    // Bind an error listener to the REST methods.
    RestUtil.on('error', _restErrorLister);

    MQ.bind(PreviewConstants.MQ.TASK_GENERATE_PREVIEWS, _handleGeneratePreviewsTask, options, function(err) {
        if (err) {
            log().error({'err': err}, 'Could not bind to the previews queue.');
            return callback(err);
        }
        log().info('Bound the preview processor to the message queue.');
        callback();
    });
};
Example #2
0
var enable = module.exports.enable = function(callback) {
    callback = callback || function(err) { /* error is logged within the implementation */ };

    // Set up the message queue and start listenening for preview tasks.
    var options = {
        'subscribe': {
            'prefetchCount': 1
        }
    };

    // Bind an error listener to the REST methods.
    RestUtil.on('error', _restErrorLister);

    MQ.bind(PreviewConstants.MQ.TASK_GENERATE_PREVIEWS, _handleGeneratePreviewsTask, options, function(err) {
        if (err) {
            log().error({'err': err}, 'Could not bind to the generate previews queue.');
            return callback(err);
        }

        log().info('Bound the preview processor to the generate previews task queue.');

        MQ.bind(PreviewConstants.MQ.TASK_REGENERATE_PREVIEWS, _handleRegeneratePreviewsTask, null, function(err) {
            if (err) {
                log().error({'err': err}, 'Could not bind to the regenerate previews queue.');
                return callback(err);
            }

            log().info('Bound the preview processor to the regenerate previews task queue.');
            return callback();
        });
    });
};
Example #3
0
var _bindRequestLogger = function() {
    var requestLog = require('oae-logger').logger('request-log');

    RestUtil.on('request', function(restCtx, url, method, data) {
        requestLog().trace({
            'restCtx': restCtx,
            'url': url,
            'method': method,
            'data': data
        }, 'Performing REST request');
    });

    RestUtil.on('response', function(body, res) {
        requestLog().trace({ 'res': res, 'body': body }, 'REST Request complete');
    });

    RestUtil.on('error', function(err, body, res) {
        requestLog().error({
            'err': err,
            'res': res,
            'body': body
        }, 'An error occurred sending a REST request');
    });
};