-
Use the
cloudpipe
module to generate a base64-encoded payload string:Note: This will require the use of
npm link
as thecloudpipe
module is not available on npmjs yetindex.js
:var cloudpipe = require('cloudpipe'); var pipe = cloudpipe.init({ url: 'http://192.168.59.103:8000/v1', username: 'admin', apiKey: '12345' }); var add = function(x, y, callback) { callback(null, x + y); return 17; }; var cloudAdd = pipe.create(add); cloudAdd(2, 4, function(err, result) { // err == null // result == 6 console.log(result); });
$ node index.js | python -mjson.tool | grep stdin | awk -F\" '{print $4}' eyJmIjoiXyQkTkRfRlVOQyQkX2Z1bmN0aW9uICh4LCB5LCBjYWxsYmFjaykge1xuICBjYWxsYmFjayhudWxsLCB4ICsgeSk7XG4gIHJldHVybiAxNztcbn0iLCJvcHRpb25zIjp7fSwiYXJncyI6eyIwIjoyLCIxIjo0LCIyIjoiXyQkTkRfRlVOQyQkX2Z1bmN0aW9uIChlcnIsIHJlc3VsdCkge1xuICAvLyBlcnIgPT0gbnVsbFxuICAvLyByZXN1bHQgPT0gNlxuICBjb25zb2xlLmxvZyhyZXN1bHQpO1xufSJ9fQ==
-
Base-64 decode the string output in the previous step:
Note: this requires the
base64
program, available as part of thecoreutils
package.$ payload=$(echo 'eyJmIjoiXyQkTkRfRlVOQyQkX2Z1bmN0aW9uICh4LCB5LCBjYWxsYmFjaykge1xuICBjYWxsYmFjayhudWxsLCB4ICsgeSk7XG4gIHJldHVybiAxNztcbn0iLCJvcHRpb25zIjp7fSwiYXJncyI6eyIwIjoyLCIxIjo0LCIyIjoiXyQkTkRfRlVOQyQkX2Z1bmN0aW9uIChlcnIsIHJlc3VsdCkge1xuICAvLyBlcnIgPT0gbnVsbFxuICAvLyByZXN1bHQgPT0gNlxuICBjb25zb2xlLmxvZyhyZXN1bHQpO1xufSJ9fQ==' | base64 --decode)
-
Pipe the payload over STDIN to the runner:
$ echo $payload | ./bin/runner.js --result-file /tmp/.result
-
Confirm that
6
was output on STDOUT and/tmp/.result
contains17
.
-
Notifications
You must be signed in to change notification settings - Fork 0
cloudpipe/runner-node
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
🏃 Service to handle jobs from sdk-node
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published