You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwhisk.apache.org by lz...@apache.org on 2017/06/06 02:44:08 UTC
[incubator-openwhisk-package-rss] branch master updated: Fix the
issue #13. (#17)
This is an automated email from the ASF dual-hosted git repository.
lz1982 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk-package-rss.git
The following commit(s) were added to refs/heads/master by this push:
new b005bc3 Fix the issue #13. (#17)
b005bc3 is described below
commit b005bc39d7c9cc36e62f7260fb0873266ebd9506
Author: David Liu <da...@cn.ibm.com>
AuthorDate: Tue Jun 6 10:44:07 2017 +0800
Fix the issue #13. (#17)
tested.
---
feeds/feed.js | 109 +++++++++++++++++++++++++++++++++-------------------------
1 file changed, 63 insertions(+), 46 deletions(-)
diff --git a/feeds/feed.js b/feeds/feed.js
index 957f504..4c8315b 100644
--- a/feeds/feed.js
+++ b/feeds/feed.js
@@ -33,63 +33,82 @@ function main(msg){
whiskhost: msg.apiHost
};
- request({
- method: "POST",
- uri: msg.provider_endpoint,
- json: newTrigger,
- auth: {
- user: msg.authKey.split(':')[0],
- pass: msg.authKey.split(':')[1]
- }
- }, function(err, res, body) {
- console.log('rss: done http request');
- if (!err && res.statusCode === 200) {
- whisk.done();
- }
- else {
- if(res) {
- console.log('rss: Error invoking whisk action:', res.statusCode, body);
- whisk.error(body.error);
+ var promise = new Promise(function (resolve, reject) {
+ request({
+ method: "POST",
+ uri: msg.provider_endpoint,
+ json: newTrigger,
+ auth: {
+ user: msg.authKey.split(':')[0],
+ pass: msg.authKey.split(':')[1]
+ }
+ }, function(err, res, body) {
+ console.log('rss: done http request');
+ if (!err && res.statusCode === 200) {
+ resolve({
+ response:res,
+ body:body
+ });
}
else {
- console.log('rss: Error invoking whisk action:', err);
- whisk.error();
+ if(res) {
+ console.log('rss: Error invoking whisk action:', res.statusCode, body);
+ reject({
+ statusCode:res.statusCode,
+ response:res
+ });
+ }
+ else {
+ console.log('rss: Error invoking whisk action:', err);
+ reject({
+ error:err
+ });
+ }
}
- }
+ });
});
- }
-
- else if (lifecycleEvent === 'DELETE'){
+ return promise;
+ } else if (lifecycleEvent === 'DELETE'){
var trigger = {
name: trigger.name,
namespace: trigger.namespace
}
-
- request({
- method: "DELETE",
- uri: msg.provider_endpoint,
- json: trigger,
- auth: {
- user: msg.authKey.split(':')[0],
- pass: msg.authKey.split(':')[1]
- }
- }, function(err, res, body) {
- console.log('rss: done http request');
- if (!err && (res.statusCode === 200 || res.statusCode === 404)) {
- whisk.done();
- }
- else {
- if(res) {
- console.log('rss: Error invoking whisk action:', res.statusCode, body);
- whisk.error(body.error);
+ var promise = new Promise(function ( resolve, reject){
+ request({
+ method: "DELETE",
+ uri: msg.provider_endpoint,
+ json: trigger,
+ auth: {
+ user: msg.authKey.split(':')[0],
+ pass: msg.authKey.split(':')[1]
+ }
+ }, function(err, res, body) {
+ console.log('rss: done http request');
+ if (!err && (res.statusCode === 200 || res.statusCode === 404)) {
+ resolve({
+ response:res,
+ body:body
+ });
}
else {
- console.log('rss: Error invoking whisk action:', err);
- whisk.error();
+ if(res) {
+ console.log('rss: Error invoking whisk action:', res.statusCode, body);
+ reject({
+ statusCode:res.statusCode,
+ response:res
+ });
+ }
+ else {
+ console.log('rss: Error invoking whisk action:', err);
+ reject({
+ error:err
+ });
+ }
}
- }
+ });
});
+ return promise;
}
function parseQName(qname) {
@@ -106,6 +125,4 @@ function main(msg){
}
return parsed;
}
-
- return whisk.async();
}
--
To stop receiving notification emails like this one, please contact
['"commits@openwhisk.apache.org" <co...@openwhisk.apache.org>'].