cfc-lib
Version:
This is a serverless function composition library for cloud function (FaaS) choreography instead of orchestration.
28 lines (25 loc) • 865 B
JavaScript
;
const fs = require('fs');
let parsedWorkflows;
const parse = (workflowJsonLocation, LOG) => {
/** If workflows haven't been read from file already, we do it here
* (this is only done in case of cold starts). **/
return new Promise((resolve, reject) => {
if (!parsedWorkflows) {
fs.readFile(workflowJsonLocation, 'utf8', (err, data) => {
if (err) {
LOG.log(err);
reject(err);
} else {
parsedWorkflows = JSON.parse(data).workflows;
resolve(parsedWorkflows);
}
}
);
} else {
resolve(parsedWorkflows);
}
});
};
exports.parse = parse;
exports.parsedWorkflows = parsedWorkflows;