2

I'm using highland to handle back pressure. My code is:

const pipeline = [{
            $match: { 'published': true, status: 'Approved' }
        }];

        const cursor = UserModel.aggregate(pipeline)
            .cursor().exec();

        // iterating over each hospitality one by one    
        highland(cursor)
            .map((doc) => {
                // some code
                return doc;
            })
            .map((doc) => {
                // some code
                return doc;
            })
            .map((doc) => {
                // some code
                return doc;
            })
            .errors(function (err) {
                winston.error('error', err);
            })
            .done(() => {
                winston.info('JOB: done');
            });

I want one document to fetch then process through map's streams one by one.

I'm not sure if this would handle backpressure because highland doc say:

Please see Back-pressure section into the highland doc.

Some streams (such as those based on events) cannot be paused. In these cases data is buffered until the consumer is ready to handle it.

Please suggest any other way if this does not handle backpressure!

Sandeep Sharma
  • 1,855
  • 3
  • 19
  • 34

0 Answers0