-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update demo to use whisk actions and -whiskserver mode.
Some problems remain. See issue #67
- Loading branch information
1 parent
e9017fd
commit 6e67380
Showing
9 changed files
with
82 additions
and
179 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
qcertJS.js | ||
qcert-runtime.js | ||
demo.js | ||
qcertPreCompiler.js | ||
qcertWhiskDispatch.js | ||
*.js.map | ||
node_modules/ |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file was deleted.
Oops, something went wrong.
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/** | ||
* Copyright (C) 2016-2017 Joshua Auerbach | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
// List URLs for the "whisk" qcert service in the order they should be attempted. It is a good idea (but not required) to put a | ||
// localhost URL first so that new functionality can be tested without perturbing publically deployed whisk actions. Note that | ||
// our long-running server (what you would run on localhost) is not actually a whisk runtime; it just emulates enough of its behavior | ||
// to run our two actions. | ||
|
||
var serverHosts = [ | ||
"http://localhost:9879", | ||
"https://openwhisk.ng.bluemix.net/api/v1/web/JoshAuerbachThoughts_test/qcert/qcert.json" | ||
]; | ||
|
||
function whiskDispatch(input: QcertCompilerConfig, callback: (result: QcertResult) => any) { | ||
var next = function() { | ||
console.log("No server found to process request, calling qcertJS.js directly"); | ||
callback(qcertCompile(input)); | ||
} | ||
for (var i = serverHosts.length - 1; i >=0; i--) | ||
next = makeHandler(input, serverHosts[i], callback, next); | ||
next(); | ||
} | ||
|
||
function makeHandler(input: QcertCompilerConfig, url: string, success: (result: QcertResult) => any, failure: () => any) { | ||
return function() { | ||
console.log("Handler invoked on URL " + url); | ||
var request = new XMLHttpRequest(); | ||
request.open("POST", url, true); | ||
request.setRequestHeader("Content-Type", "application/json"); | ||
request.onloadend = function() { | ||
if (request.status == 200) { | ||
console.log("Success at url " + url); | ||
var response = JSON.parse(request.responseText); | ||
success(response); | ||
} else { | ||
console.log("Failure at url " + url); | ||
failure(); | ||
} | ||
} | ||
try { | ||
console.log("Posting request on url " + url); | ||
request.send(JSON.stringify(input)); | ||
} catch (e) { | ||
} | ||
} | ||
} | ||
|
||
function qcertWhiskDispatch(input: QcertCompilerConfig, callback: (result: QcertResult) => any) { | ||
var handler = function(result: QcertResult) { | ||
if (result.result.substring(0, 6) == "ERROR:") | ||
console.log("Calling back with error: " + result.result); | ||
else | ||
console.log("Calling back after success"); | ||
callback(result); | ||
} | ||
console.log("Dispatching whiskDispatch"); | ||
whiskDispatch(input, handler); | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,7 @@ | |
"demo.ts", | ||
"typings.d.ts", | ||
"qcertJS.d.ts", | ||
"qcertPreCompiler.ts" | ||
"qcertWhiskDispatch.ts" | ||
] | ||
} | ||
|