Question: Running facts in batches
Firstly thanks a lot for this library! Working with this has been a pleasure!
I wrapped your library in a REST API. I then sent it batches of anything from 100 to a 1000 records / facts to evaluate. The API call must only resolve once all the facts have been evaluated. I achieved it using Q like below.
function run(facts) {
var promises = [];
facts.forEach(function(value, key) {
promises.push(perFactRuleRunner(value));
});
return Q.all(promises);
}
function perFactRuleRunner(fact) {
var defer = Q.defer();
R.execute(fact, function(data) {
defer.resolve(data);
}, function(error){
defer.reject(error);
});
return defer.promise;
}
Is there a builtin way to achieve the same result, or must I stick with this?
This is not supported in the current version - 4.0.0.
@phzietsman Can you please tell me how can I get the response data using this code for a bunch of facts?
@phzietsman Can you please tell me how can I get the response data using this code for a bunch of facts?
This has been a while.
I'd swap out Q for native Javascript promises and look at promise all (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/all)
Hey thanks for the feedback. Please consider raising a PR incase you have any directions on improving the existing flow control apis. Closing since there is no open items that can be picked up as a bug or feature addition.