Skip to content

Instantly share code, notes, and snippets.

@rkdgusrnrlrl
Created May 29, 2018 05:08
Show Gist options
  • Save rkdgusrnrlrl/1d5ef1b4cde8fc8291088fcb695c289f to your computer and use it in GitHub Desktop.
Save rkdgusrnrlrl/1d5ef1b4cde8fc8291088fcb695c289f to your computer and use it in GitHub Desktop.
async queue를 활용한 분산 처리
const async = require('async');
// 워커 함수
function worker(data) {
console.log(data);
}
// 큐 생성
let queue = async.queue(function(data, cb) {
worker(data);
cb();
}, 10);
// 완료시 종료
queue.drain = function () {
logger.info("queue is drain");
process.exit(0)
};
// 큐에 값 넣기
queue.push(["helle", "world"]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment