Created
June 7, 2019 09:05
-
-
Save srfrnk/8f9989b81b10c4b929d32eda257fe50a 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 express = require('express'); | |
const bodyParser = require('body-parser'); | |
const path = require('path'); | |
const fs = require('fs'); | |
. | |
. | |
. | |
var app = express(); | |
app.use(bodyParser.json()); | |
app.post('/sync', function (req, res) { | |
const parent = req.body.parent; | |
// const children = req.body.children; | |
const response = { | |
"status": {}, | |
"children": getChildren(parent.metadata.name, parent.spec) | |
}; | |
if (DEBUG_LOG) { | |
console.log(JSON.stringify({ type: "SYNC", req: req.body, res: response }), ","); | |
} | |
res.json(response); | |
}); | |
app.listen(80, () => { | |
console.log("Flink controller running!"); | |
}); | |
function getChildren(jobName, spec) { | |
const configMapName = `flink-job-jar-${jobName}`; | |
const version = spec.version || 'NoVersion'; | |
const controller = getController(jobName, version, configMapName, spec); | |
const configMap = getConfigMap(version, configMapName); | |
return [configMap, controller]; | |
} | |
function getController(jobName, version, configMapName, spec) { | |
if (!!spec.streaming) { | |
return getStatefulset(jobName, version, configMapName, spec); | |
} | |
if (!!spec.cron) { | |
return getCronJob(jobName, version, configMapName, spec); | |
} | |
console.log(`Job '${jobName}': Must specify either 'streaming' or 'cron' properties in spec. No controller is created for job.`); | |
} | |
function getStatefulset(jobName, version, configMapName, spec) { | |
. | |
. | |
. | |
} | |
function getCronJob(jobName, version, configMapName, spec) { | |
. | |
. | |
. | |
} | |
function getConfigMap(version, configMapName) { | |
. | |
. | |
. | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment