dubeejw commented on a change in pull request #2730: Reduce memory consumption 
for action invocation
URL: 
https://github.com/apache/incubator-openwhisk/pull/2730#discussion_r138198691
 
 

 ##########
 File path: common/scala/src/main/scala/whisk/core/entity/Exec.scala
 ##########
 @@ -278,3 +376,132 @@ protected[core] object Exec extends ArgNormalizer[Exec] 
with DefaultJsonProtocol
     } else false
   }
 }
+
+protected[core] object Exec2 extends ArgNormalizer[Exec2] with 
DefaultJsonProtocol {
+
+  val sizeLimit = 48 MB
+
+  // The possible values of the JSON 'kind' field for certain runtimes:
+  // - Sequence because it is an intrinsic
+  // - Black Box because it is a type marker
+  protected[core] val SEQUENCE = "sequence"
+  protected[core] val BLACKBOX = "blackbox"
+
+  private def execManifests = ExecManifest.runtimesManifest
+
+  override protected[core] implicit lazy val serdes = new 
RootJsonFormat[Exec2] {
+    private def attFmt[T: JsonFormat] = Attachments.serdes[T]
+    private lazy val runtimes: Set[String] = 
execManifests.knownContainerRuntimes ++ Set(SEQUENCE, BLACKBOX)
+
+    override def write(e: Exec2) = e match {
+      case c: CodeExecAsString2 =>
+        val base = Map("kind" -> JsString(c.kind), "binary" -> 
JsBoolean(c.binary))
+        val main = c.entryPoint.map("main" -> JsString(_))
+        JsObject(base ++ main)
+
+      case a: CodeExecAsAttachment2 =>
+        val base =
+          Map("kind" -> JsString(a.kind), "binary" -> JsBoolean(a.binary))
+        val main = a.entryPoint.map("main" -> JsString(_))
+        JsObject(base ++ main)
+
+      case s @ SequenceExec2(comp) =>
+        JsObject("kind" -> JsString(s.kind), "components" -> 
comp.map(_.qualifiedNameWithLeadingSlash).toJson)
+
+      case b: BlackBoxExec2 =>
+        val base =
+          Map("kind" -> JsString(b.kind), "image" -> 
JsString(b.image.publicImageName), "binary" -> JsBoolean(b.binary))
+        //val code = b.code.filter(_.trim.nonEmpty).map("code" -> JsString(_))
 
 Review comment:
   TODO: delete.
 
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to