markusthoemmes commented on a change in pull request #2584: SPI for Loadbalancer
URL: 
https://github.com/apache/incubator-openwhisk/pull/2584#discussion_r132406052
 
 

 ##########
 File path: 
core/controller/src/main/scala/whisk/core/loadBalancer/LoadBalancerService.scala
 ##########
 @@ -275,6 +296,14 @@ class LoadBalancerService(
     private def generateHash(namespace: EntityName, action: 
ExecutableWhiskAction): Int = {
         (namespace.asString.hashCode() ^ 
action.fullyQualifiedName(false).asString.hashCode()).abs
     }
+
+    /** Returns a Map of invoker instance -> invoker state */
+    override def getHealthResponse(): Future[JsObject] = {
+        val res = allInvokers.map(_.map {
+            case (instance, state) => s"invoker${instance.toInt}" -> 
state.asString
+        }.toMap.toJson.asJsObject)
+        res
 
 Review comment:
   There is no need to store the intermediary result:
   
   ```scala
   override def getHealthResponse(): Future[JsObject] = allInvokers.map(_.map {
           case (instance, state) => s"invoker${instance.toInt}" -> 
state.asString
       }.toMap.toJson.asJsObject)
   ```
   
   Also please refrain from using java style getter names like 
`getHealthResponse`. I suggest `LoadBalancer.healthStatus()`.
 
----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to