Commit f7a0de90 authored by nilanjandaw's avatar nilanjandaw
parents 66a27d36 bf332d2a
......@@ -14,7 +14,7 @@ const libSupport = require('./lib')
let db = new Map()
app.use(morgan('combined'))
app.use(bodyParser.urlencoded({ extended: false }))
app.use(bodyParser.urlencoded({ extended: true }))
app.use(bodyParser.json())
const file_path = __dirname + "/repository/"
......@@ -137,10 +137,11 @@ function dispatch() {
let lookbackWindow = Math.min(WINDOW_SIZE, requestQueue.length)
for (let i = 0; i < lookbackWindow; i++) {
let {req, res} = requestQueue.shift()
console.log(req.body)
let runtime = req.body.runtime
let functionHash = req.params.id
let function_id = libSupport.makeid(20)
console.log("Dispatching function with Id", function_id);
console.log("Dispatching function with Id", function_id, runtime);
let node_id = getAddress()
client.publish(node_id, JSON.stringify({
"type": "execute",
......@@ -170,10 +171,10 @@ client.on('message', function (topic, message) {
db.delete(message.function_id)
} else if (topic === "heartbeat") {
message = JSON.parse(message)
if (workerNodes.indexOf(message.address) === -1)
if (workerNodes.indexOf(message.address) === -1) {
workerNodes.push(message.address)
console.log(workerNodes);
console.log(workerNodes);
}
}
})
......@@ -184,4 +185,4 @@ client.on('connect', function () {
client.subscribe("heartbeat")
})
setInterval(dispatch, 1000);
\ No newline at end of file
setInterval(dispatch, 1000);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment