Created
June 28, 2019 07:29
-
-
Save e7h4n/6b7ea3e0e0fea1ec6b2f4b07f619c519 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 getA = function(cb) { | |
cb(a); | |
} | |
const getB = function(a, cb) { | |
cb(b); | |
} | |
const getC = function(a, b, cb) { | |
cb(c); | |
} | |
const getD = function(b, c, cb) { | |
cb(d); | |
} | |
const getE = function(d, cb) { | |
cb(d); | |
} | |
// 依赖关系定义 | |
const depTree = { | |
a: { | |
deps: [], | |
method: getA, | |
retryLimit: 3, | |
}, | |
b: { | |
deps: ['a'], | |
method: getB, | |
retryLimit: 3, | |
}, | |
c: { | |
deps: ['a', 'b'], | |
method: getC, | |
retryLimit: 3, | |
}, | |
d: { | |
deps: ['b', 'c'], | |
method: getD, | |
retryLimit: 3, | |
}, | |
main: { | |
deps: ['d'], | |
method: getE, | |
retryLimit: 3, | |
}, | |
}; | |
depExec(depTree, e => { | |
console.log(e); | |
}); | |
// TODO: 解析 depTree,尽可能并行地去拉取数据,对外返回 main 任务的 method 结果 | |
function depExec(tree, cb) { | |
// fill this | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment