Created
May 29, 2018 05:08
-
-
Save rkdgusrnrlrl/1d5ef1b4cde8fc8291088fcb695c289f to your computer and use it in GitHub Desktop.
async queue를 활용한 분산 처리
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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