You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwhisk.apache.org by ma...@apache.org on 2017/08/17 15:45:46 UTC
[incubator-openwhisk] branch master updated: Patch posting of
trigger activation. (#2613)
This is an automated email from the ASF dual-hosted git repository.
markusthoemmes pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk.git
The following commit(s) were added to refs/heads/master by this push:
new d6edfde Patch posting of trigger activation. (#2613)
d6edfde is described below
commit d6edfde20b3fbaa5ff173761717e8158f28910b3
Author: rodric rabbah <ro...@gmail.com>
AuthorDate: Thu Aug 17 11:45:43 2017 -0400
Patch posting of trigger activation. (#2613)
---
.../scala/whisk/core/controller/Triggers.scala | 30 ++++++++++++----------
1 file changed, 17 insertions(+), 13 deletions(-)
diff --git a/core/controller/src/main/scala/whisk/core/controller/Triggers.scala b/core/controller/src/main/scala/whisk/core/controller/Triggers.scala
index 6e0028c..fe5304f 100644
--- a/core/controller/src/main/scala/whisk/core/controller/Triggers.scala
+++ b/core/controller/src/main/scala/whisk/core/controller/Triggers.scala
@@ -24,12 +24,10 @@ import scala.concurrent.Future
import scala.util.{ Failure, Success }
import akka.actor.ActorSystem
+import akka.stream.ActorMaterializer
import akka.http.scaladsl.model.headers.BasicHttpCredentials
import akka.http.scaladsl.model.HttpRequest
-import akka.http.scaladsl.model.StatusCodes
-import akka.http.scaladsl.model.StatusCodes.BadRequest
-import akka.http.scaladsl.model.StatusCodes.InternalServerError
-import akka.http.scaladsl.model.StatusCodes.OK
+import akka.http.scaladsl.model.StatusCodes._
import akka.http.scaladsl.model.Uri
import akka.http.scaladsl.model.Uri.Path
import akka.http.scaladsl.server.RouteResult
@@ -40,9 +38,8 @@ import akka.http.scaladsl.model.MediaTypes
import akka.http.scaladsl.model.HttpEntity
import akka.http.scaladsl.server.RequestContext
import akka.http.scaladsl.Http
-import akka.http.scaladsl.model.HttpResponse
-import akka.stream.ActorMaterializer
import akka.http.scaladsl.marshallers.sprayjson.SprayJsonSupport._
+import akka.http.scaladsl.unmarshalling.Unmarshal
import spray.json._
import spray.json.DefaultJsonProtocol.RootJsObjectFormat
@@ -144,6 +141,7 @@ trait WhiskTriggersApi extends WhiskCollectionAPI {
val saveTriggerActivation = WhiskActivation.put(activationStore, triggerActivation) map {
_ => triggerActivationId
}
+
val url = Uri(s"http://localhost:${whiskConfig.servicePort}")
trigger.rules.map {
@@ -173,6 +171,7 @@ trait WhiskTriggersApi extends WhiskCollectionAPI {
Path.SingleSlash + rule.action.name.asString
}
}.toString
+
val actionUrl = Path("/api/v1") / "namespaces" / actionNamespace / "actions"
val request = HttpRequest(
method = POST,
@@ -180,13 +179,18 @@ trait WhiskTriggersApi extends WhiskCollectionAPI {
headers = List(Authorization(BasicHttpCredentials(user.authkey.uuid.asString, user.authkey.key.asString))),
entity = HttpEntity(MediaTypes.`application/json`, args.getOrElse(JsObject()).compactPrint))
- Http().singleRequest(request).map {
- case HttpResponse(StatusCodes.OK, headers, entity, _) =>
- logging.info(this, s"successfully invoked ${rule.action} -> ")
- case HttpResponse(StatusCodes.NotFound, _, _, _) =>
- logging.info(this, s"action ${rule.action} could not be found")
- case HttpResponse(code, _, entity, _) =>
- logging.warn(this, s"action ${rule.action} could not be invoked due to ${entity.getDataBytes.toString}")
+ Http().singleRequest(request).map { response =>
+ response.status match {
+ case OK | Accepted => Unmarshal(response.entity).to[JsObject].map { a =>
+ logging.info(this, s"${rule.action} activated ${a.fields("activationId")}")
+ }
+ case NotFound =>
+ response.discardEntityBytes()
+ logging.info(this, s"${rule.action} failed, action not found")
+ case _ => Unmarshal(response.entity).to[String].map { error =>
+ logging.warn(this, s"${rule.action} failed due to $error")
+ }
+ }
}
}
}
--
To stop receiving notification emails like this one, please contact
['"commits@openwhisk.apache.org" <co...@openwhisk.apache.org>'].