我有一组命令对象。我需要调用 do 命令,这是一个异步调用,按顺序对每个数组元素进行。如果有任何失败,我需要停止处理。
我知道如何为个人异步调用执行 async.waterfall 调用,但我不知道如何将异步调用数组传递给 async.waterfall。
从语法上不确定如何设置它。
这是命令对象,读取函数是我需要以瀑布方式执行的异步调用...
var ICommand = require('./command');
function FabricCommand (name) {
this.name = name;
this.fabric = '';
ICommand.call(this);
}
// inherit ICommand
FabricCommand.prototype = new ICommand();
FabricCommand.prototype.read = function () {
var URL = require('url');
var Fabric = require('./rsp_fabrics_port_status_s');
var ResponseVerifier = require('./rsp_mgmt_rsp_s');
var client = require('./soap_client').getInstance();
if (client === null) {
throw new Error('Failed to connect to SOAP server!');
}
var xml = '<urn:mgmtSystemGetInterfaceStatus>' +
'<interface xsi:type=\'xsd:string\'>' + this.name + '</interface>' +
'</urn:mgmtSystemGetInterfaceStatus>';
client.MgmtServer.MgmtServer.mgmtSystemGetInterfaceStatus(xml, function (err, result) {
console.log('got the response from the backend for mgmtSystemGetInterfaceStatus');
if (err) {
throw new Error(err);
}
var rs = new ResponseVerifier(result.rsp);
if (rs.failed()) {
throw new Error(rs.getErrorMessage())
}
this.fabric = new Fabric(result.rsp.portStatus.item[0]);
});
};