wonder.js
Version:
204 lines (189 loc) • 12.1 kB
JavaScript
'use strict';
var List = require("bs-platform/lib/js/list.js");
var Curry = require("bs-platform/lib/js/curry.js");
var Caml_array = require("bs-platform/lib/js/caml_array.js");
var Pervasives = require("bs-platform/lib/js/pervasives.js");
var JobService$Wonderjs = require("../../../../primitive/job/JobService.js");
var HandleJobService$Wonderjs = require("../../../../primitive/job/HandleJobService.js");
var ArrayService$WonderCommonlib = require("wonder-commonlib/lib/js/src/ArrayService.js");
var OperateNoWorkerJobService$Wonderjs = require("../../../../record/main/noWorkerJob/OperateNoWorkerJobService.js");
var MutableHashMapService$WonderCommonlib = require("wonder-commonlib/lib/js/src/MutableHashMapService.js");
function _getAllNoWorkerJobs(executableJobs, jobHandleMap, state) {
return ArrayService$WonderCommonlib.reduceOneParam((function (list, param) {
var name = param[/* name */0];
var match = MutableHashMapService$WonderCommonlib.get(name, jobHandleMap);
if (match !== undefined) {
return Pervasives.$at(list, /* :: */[
/* tuple */[
name,
Curry._1(match, param[/* flags */1])
],
/* [] */0
]);
} else {
return JobService$Wonderjs.handleGetNoneNoWorkerJob(name, list);
}
}), /* [] */0, executableJobs);
}
function _getNoWorkerInitJobList(state) {
return state[/* jobRecord */1][/* noWorkerInitJobList */0];
}
function _getNoWorkerLoopJobList(state) {
return state[/* jobRecord */1][/* noWorkerLoopJobList */1];
}
function execNoWorkerInitJobs(state) {
return List.fold_left((function (state, param) {
return Curry._1(param[1], state);
}), state, state[/* jobRecord */1][/* noWorkerInitJobList */0]);
}
function execNoWorkerLoopJobs(state) {
return List.fold_left((function (state, param) {
return Curry._1(param[1], state);
}), state, state[/* jobRecord */1][/* noWorkerLoopJobList */1]);
}
function init(param, state) {
var jobRecord = state[/* jobRecord */1];
var newrecord = Caml_array.caml_array_dup(state);
var __x = Curry._1(param[0], /* () */0);
var __x$1 = Curry._1(param[1], /* () */0);
newrecord[/* jobRecord */1] = /* record */[
/* noWorkerInitJobList */_getAllNoWorkerJobs(OperateNoWorkerJobService$Wonderjs.getInitPipelineExecutableJobs(OperateNoWorkerJobService$Wonderjs.getSetting(state[/* noWorkerJobRecord */2]), OperateNoWorkerJobService$Wonderjs.getInitPipelines(state[/* noWorkerJobRecord */2]), OperateNoWorkerJobService$Wonderjs.getInitJobs(state[/* noWorkerJobRecord */2])), HandleJobService$Wonderjs.concatJobHandleMaps(__x, jobRecord[/* noWorkerCustomInitJobHandleMap */2]), state),
/* noWorkerLoopJobList */_getAllNoWorkerJobs(OperateNoWorkerJobService$Wonderjs.getLoopPipelineExecutableJobs(OperateNoWorkerJobService$Wonderjs.getSetting(state[/* noWorkerJobRecord */2]), OperateNoWorkerJobService$Wonderjs.getLoopPipelines(state[/* noWorkerJobRecord */2]), OperateNoWorkerJobService$Wonderjs.getLoopJobs(state[/* noWorkerJobRecord */2])), HandleJobService$Wonderjs.concatJobHandleMaps(__x$1, jobRecord[/* noWorkerCustomLoopJobHandleMap */3]), state),
/* noWorkerCustomInitJobHandleMap */jobRecord[/* noWorkerCustomInitJobHandleMap */2],
/* noWorkerCustomLoopJobHandleMap */jobRecord[/* noWorkerCustomLoopJobHandleMap */3],
/* workerCustomMainInitTargetJobMap */jobRecord[/* workerCustomMainInitTargetJobMap */4],
/* workerCustomMainInitSourceJobMap */jobRecord[/* workerCustomMainInitSourceJobMap */5],
/* workerCustomMainInitRemovedDefaultJobMap */jobRecord[/* workerCustomMainInitRemovedDefaultJobMap */6],
/* workerCustomMainLoopTargetJobMap */jobRecord[/* workerCustomMainLoopTargetJobMap */7],
/* workerCustomMainLoopSourceJobMap */jobRecord[/* workerCustomMainLoopSourceJobMap */8],
/* workerCustomMainLoopRemovedDefaultJobMap */jobRecord[/* workerCustomMainLoopRemovedDefaultJobMap */9]
];
return newrecord;
}
function registerNoWorkerInitJob(jobName, handleFunc, state) {
var jobRecord = state[/* jobRecord */1];
var newrecord = Caml_array.caml_array_dup(state);
var init = state[/* jobRecord */1];
newrecord[/* jobRecord */1] = /* record */[
/* noWorkerInitJobList */init[/* noWorkerInitJobList */0],
/* noWorkerLoopJobList */init[/* noWorkerLoopJobList */1],
/* noWorkerCustomInitJobHandleMap */MutableHashMapService$WonderCommonlib.set(jobName, handleFunc, jobRecord[/* noWorkerCustomInitJobHandleMap */2]),
/* noWorkerCustomLoopJobHandleMap */init[/* noWorkerCustomLoopJobHandleMap */3],
/* workerCustomMainInitTargetJobMap */init[/* workerCustomMainInitTargetJobMap */4],
/* workerCustomMainInitSourceJobMap */init[/* workerCustomMainInitSourceJobMap */5],
/* workerCustomMainInitRemovedDefaultJobMap */init[/* workerCustomMainInitRemovedDefaultJobMap */6],
/* workerCustomMainLoopTargetJobMap */init[/* workerCustomMainLoopTargetJobMap */7],
/* workerCustomMainLoopSourceJobMap */init[/* workerCustomMainLoopSourceJobMap */8],
/* workerCustomMainLoopRemovedDefaultJobMap */init[/* workerCustomMainLoopRemovedDefaultJobMap */9]
];
return newrecord;
}
function registerNoWorkerLoopJob(jobName, handleFunc, state) {
var jobRecord = state[/* jobRecord */1];
var newrecord = Caml_array.caml_array_dup(state);
var init = state[/* jobRecord */1];
newrecord[/* jobRecord */1] = /* record */[
/* noWorkerInitJobList */init[/* noWorkerInitJobList */0],
/* noWorkerLoopJobList */init[/* noWorkerLoopJobList */1],
/* noWorkerCustomInitJobHandleMap */init[/* noWorkerCustomInitJobHandleMap */2],
/* noWorkerCustomLoopJobHandleMap */MutableHashMapService$WonderCommonlib.set(jobName, handleFunc, jobRecord[/* noWorkerCustomLoopJobHandleMap */3]),
/* workerCustomMainInitTargetJobMap */init[/* workerCustomMainInitTargetJobMap */4],
/* workerCustomMainInitSourceJobMap */init[/* workerCustomMainInitSourceJobMap */5],
/* workerCustomMainInitRemovedDefaultJobMap */init[/* workerCustomMainInitRemovedDefaultJobMap */6],
/* workerCustomMainLoopTargetJobMap */init[/* workerCustomMainLoopTargetJobMap */7],
/* workerCustomMainLoopSourceJobMap */init[/* workerCustomMainLoopSourceJobMap */8],
/* workerCustomMainLoopRemovedDefaultJobMap */init[/* workerCustomMainLoopRemovedDefaultJobMap */9]
];
return newrecord;
}
function addNoWorkerInitJob(param, action, targetHandleFunc, state) {
var newrecord = Caml_array.caml_array_dup(state);
var init = state[/* jobRecord */1];
newrecord[/* jobRecord */1] = /* record */[
/* noWorkerInitJobList */JobService$Wonderjs.addJob(/* tuple */[
param[0],
param[1],
action,
targetHandleFunc
], state[/* jobRecord */1][/* noWorkerInitJobList */0]),
/* noWorkerLoopJobList */init[/* noWorkerLoopJobList */1],
/* noWorkerCustomInitJobHandleMap */init[/* noWorkerCustomInitJobHandleMap */2],
/* noWorkerCustomLoopJobHandleMap */init[/* noWorkerCustomLoopJobHandleMap */3],
/* workerCustomMainInitTargetJobMap */init[/* workerCustomMainInitTargetJobMap */4],
/* workerCustomMainInitSourceJobMap */init[/* workerCustomMainInitSourceJobMap */5],
/* workerCustomMainInitRemovedDefaultJobMap */init[/* workerCustomMainInitRemovedDefaultJobMap */6],
/* workerCustomMainLoopTargetJobMap */init[/* workerCustomMainLoopTargetJobMap */7],
/* workerCustomMainLoopSourceJobMap */init[/* workerCustomMainLoopSourceJobMap */8],
/* workerCustomMainLoopRemovedDefaultJobMap */init[/* workerCustomMainLoopRemovedDefaultJobMap */9]
];
return newrecord;
}
function addNoWorkerLoopJob(param, action, targetHandleFunc, state) {
var newrecord = Caml_array.caml_array_dup(state);
var init = state[/* jobRecord */1];
newrecord[/* jobRecord */1] = /* record */[
/* noWorkerInitJobList */init[/* noWorkerInitJobList */0],
/* noWorkerLoopJobList */JobService$Wonderjs.addJob(/* tuple */[
param[0],
param[1],
action,
targetHandleFunc
], state[/* jobRecord */1][/* noWorkerLoopJobList */1]),
/* noWorkerCustomInitJobHandleMap */init[/* noWorkerCustomInitJobHandleMap */2],
/* noWorkerCustomLoopJobHandleMap */init[/* noWorkerCustomLoopJobHandleMap */3],
/* workerCustomMainInitTargetJobMap */init[/* workerCustomMainInitTargetJobMap */4],
/* workerCustomMainInitSourceJobMap */init[/* workerCustomMainInitSourceJobMap */5],
/* workerCustomMainInitRemovedDefaultJobMap */init[/* workerCustomMainInitRemovedDefaultJobMap */6],
/* workerCustomMainLoopTargetJobMap */init[/* workerCustomMainLoopTargetJobMap */7],
/* workerCustomMainLoopSourceJobMap */init[/* workerCustomMainLoopSourceJobMap */8],
/* workerCustomMainLoopRemovedDefaultJobMap */init[/* workerCustomMainLoopRemovedDefaultJobMap */9]
];
return newrecord;
}
function removeNoWorkerInitJob(targetJobName, state) {
var newrecord = Caml_array.caml_array_dup(state);
var init = state[/* jobRecord */1];
newrecord[/* jobRecord */1] = /* record */[
/* noWorkerInitJobList */JobService$Wonderjs.removeJob(targetJobName, state[/* jobRecord */1][/* noWorkerInitJobList */0]),
/* noWorkerLoopJobList */init[/* noWorkerLoopJobList */1],
/* noWorkerCustomInitJobHandleMap */init[/* noWorkerCustomInitJobHandleMap */2],
/* noWorkerCustomLoopJobHandleMap */init[/* noWorkerCustomLoopJobHandleMap */3],
/* workerCustomMainInitTargetJobMap */init[/* workerCustomMainInitTargetJobMap */4],
/* workerCustomMainInitSourceJobMap */init[/* workerCustomMainInitSourceJobMap */5],
/* workerCustomMainInitRemovedDefaultJobMap */init[/* workerCustomMainInitRemovedDefaultJobMap */6],
/* workerCustomMainLoopTargetJobMap */init[/* workerCustomMainLoopTargetJobMap */7],
/* workerCustomMainLoopSourceJobMap */init[/* workerCustomMainLoopSourceJobMap */8],
/* workerCustomMainLoopRemovedDefaultJobMap */init[/* workerCustomMainLoopRemovedDefaultJobMap */9]
];
return newrecord;
}
function removeNoWorkerLoopJob(targetJobName, state) {
var newrecord = Caml_array.caml_array_dup(state);
var init = state[/* jobRecord */1];
newrecord[/* jobRecord */1] = /* record */[
/* noWorkerInitJobList */init[/* noWorkerInitJobList */0],
/* noWorkerLoopJobList */JobService$Wonderjs.removeJob(targetJobName, state[/* jobRecord */1][/* noWorkerLoopJobList */1]),
/* noWorkerCustomInitJobHandleMap */init[/* noWorkerCustomInitJobHandleMap */2],
/* noWorkerCustomLoopJobHandleMap */init[/* noWorkerCustomLoopJobHandleMap */3],
/* workerCustomMainInitTargetJobMap */init[/* workerCustomMainInitTargetJobMap */4],
/* workerCustomMainInitSourceJobMap */init[/* workerCustomMainInitSourceJobMap */5],
/* workerCustomMainInitRemovedDefaultJobMap */init[/* workerCustomMainInitRemovedDefaultJobMap */6],
/* workerCustomMainLoopTargetJobMap */init[/* workerCustomMainLoopTargetJobMap */7],
/* workerCustomMainLoopSourceJobMap */init[/* workerCustomMainLoopSourceJobMap */8],
/* workerCustomMainLoopRemovedDefaultJobMap */init[/* workerCustomMainLoopRemovedDefaultJobMap */9]
];
return newrecord;
}
exports._getAllNoWorkerJobs = _getAllNoWorkerJobs;
exports._getNoWorkerInitJobList = _getNoWorkerInitJobList;
exports._getNoWorkerLoopJobList = _getNoWorkerLoopJobList;
exports.execNoWorkerInitJobs = execNoWorkerInitJobs;
exports.execNoWorkerLoopJobs = execNoWorkerLoopJobs;
exports.init = init;
exports.registerNoWorkerInitJob = registerNoWorkerInitJob;
exports.registerNoWorkerLoopJob = registerNoWorkerLoopJob;
exports.addNoWorkerInitJob = addNoWorkerInitJob;
exports.addNoWorkerLoopJob = addNoWorkerLoopJob;
exports.removeNoWorkerInitJob = removeNoWorkerInitJob;
exports.removeNoWorkerLoopJob = removeNoWorkerLoopJob;
/* JobService-Wonderjs Not a pure module */