chore(JobExecutor#_execCall): forEach+Array#push → mapToArray

This commit is contained in:
Julien Fontanet 2016-08-17 18:13:30 +02:00
parent d08a04959c
commit 6c4e57aae0

View File

@ -11,7 +11,7 @@ import { BaseError } from 'make-error'
import { crossProduct } from './math' import { crossProduct } from './math'
import { import {
forEach, mapToArray,
serializeError, serializeError,
thunkToArray thunkToArray
} from './utils' } from './utils'
@ -136,7 +136,6 @@ export default class JobExecutor {
: [{}] // One call with no parameters : [{}] // One call with no parameters
const connection = this.xo.createUserConnection() const connection = this.xo.createUserConnection()
const promises = []
connection.set('user_id', job.userId) connection.set('user_id', job.userId)
@ -146,7 +145,7 @@ export default class JobExecutor {
calls: {} calls: {}
} }
forEach(paramsFlatVector, params => { const promises = mapToArray(paramsFlatVector, params => {
const runCallId = this._logger.notice(`Starting ${job.method} call. (${job.id})`, { const runCallId = this._logger.notice(`Starting ${job.method} call. (${job.id})`, {
event: 'jobCall.start', event: 'jobCall.start',
runJobId, runJobId,
@ -160,8 +159,7 @@ export default class JobExecutor {
start: Date.now() start: Date.now()
} }
promises.push( return this.xo.callApiMethod(connection, job.method, assign({}, params)).then(
this.xo.callApiMethod(connection, job.method, assign({}, params)).then(
value => { value => {
this._logger.notice(`Call ${job.method} (${runCallId}) is a success. (${job.id})`, { this._logger.notice(`Call ${job.method} (${runCallId}) is a success. (${job.id})`, {
event: 'jobCall.end', event: 'jobCall.end',
@ -185,7 +183,6 @@ export default class JobExecutor {
call.end = Date.now() call.end = Date.now()
} }
) )
)
}) })
connection.close() connection.close()