From 5fc079464dabb7f7dae150c4f7b4c7cd8596e988 Mon Sep 17 00:00:00 2001
From: Richard Alam <ritzalam@gmail.com>
Date: Fri, 7 Feb 2020 15:19:10 -0800
Subject: [PATCH]  - try to setup actor context

---
 .../src/main/scala/org/bigbluebutton/ApiService.scala |  7 ++++---
 .../src/main/scala/org/bigbluebutton/Boot.scala       | 11 +++++++----
 .../org/bigbluebutton/service/HealthzService.scala    |  4 ++++
 3 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/akka-bbb-fsesl/src/main/scala/org/bigbluebutton/ApiService.scala b/akka-bbb-fsesl/src/main/scala/org/bigbluebutton/ApiService.scala
index 2ee19fed11..b319edb9ec 100755
--- a/akka-bbb-fsesl/src/main/scala/org/bigbluebutton/ApiService.scala
+++ b/akka-bbb-fsesl/src/main/scala/org/bigbluebutton/ApiService.scala
@@ -6,15 +6,16 @@ import akka.actor.ActorSystem
 import akka.http.scaladsl.server.Directives._
 import akka.stream.Materializer
 import com.google.gson.Gson
-import org.bigbluebutton.service.HealthzResponse
+import org.bigbluebutton.service.{HealthzResponse, HealthzService}
 
-class ApiService()(implicit executor: ExecutionContext, as: ActorSystem, mat: Materializer) {
+class ApiService(healthz: HealthzService)(implicit executor: ExecutionContext, as: ActorSystem, mat: Materializer) {
 
   def routes =
     path("healthz") {
       get {
+        val resp = healthz.getHealthz()
         val gson = new Gson()
-        val response = new HealthzResponse("ok", "fine")
+        val response = new HealthzResponse(resp, "fine")
         complete(StatusCodes.ServiceUnavailable, HttpEntity(ContentTypes.`application/json`, gson.toJson(response)))
       }
     }
diff --git a/akka-bbb-fsesl/src/main/scala/org/bigbluebutton/Boot.scala b/akka-bbb-fsesl/src/main/scala/org/bigbluebutton/Boot.scala
index 3674178093..1f0c6dedeb 100755
--- a/akka-bbb-fsesl/src/main/scala/org/bigbluebutton/Boot.scala
+++ b/akka-bbb-fsesl/src/main/scala/org/bigbluebutton/Boot.scala
@@ -1,15 +1,17 @@
 package org.bigbluebutton
 
 import org.bigbluebutton.common2.bus.IncomingJsonMessageBus
-import org.bigbluebutton.common2.redis.{ RedisConfig, RedisPublisher }
+import org.bigbluebutton.common2.redis.{RedisConfig, RedisPublisher}
 import org.bigbluebutton.endpoint.redis.FSESLRedisSubscriberActor
-import org.bigbluebutton.freeswitch.{ RxJsonMsgHdlrActor, VoiceConferenceService }
+import org.bigbluebutton.freeswitch.{RxJsonMsgHdlrActor, VoiceConferenceService}
 import org.bigbluebutton.freeswitch.voice.FreeswitchConferenceEventListener
-import org.bigbluebutton.freeswitch.voice.freeswitch.{ ConnectionManager, ESLEventListener, FreeswitchApplication }
+import org.bigbluebutton.freeswitch.voice.freeswitch.{ConnectionManager, ESLEventListener, FreeswitchApplication}
 import org.freeswitch.esl.client.manager.DefaultManagerConnection
 import akka.actor.ActorSystem
 import akka.stream.ActorMaterializer
 import akka.http.scaladsl.Http
+import org.bigbluebutton.service.HealthzService
+
 import scala.concurrent.ExecutionContext
 
 object Boot extends App with SystemConfiguration with WebApi {
@@ -60,7 +62,8 @@ object Boot extends App with SystemConfiguration with WebApi {
     "redis-subscriber"
   )
 
-  val apiService = new ApiService()
+  val healthz = HealthzService()(system.)
+  val apiService = new ApiService(healthz)
 
   val bindingFuture = Http().bindAndHandle(apiService.routes, httpHost, httpPort)
 
diff --git a/akka-bbb-fsesl/src/main/scala/org/bigbluebutton/service/HealthzService.scala b/akka-bbb-fsesl/src/main/scala/org/bigbluebutton/service/HealthzService.scala
index 54a1b10549..8c550c175f 100755
--- a/akka-bbb-fsesl/src/main/scala/org/bigbluebutton/service/HealthzService.scala
+++ b/akka-bbb-fsesl/src/main/scala/org/bigbluebutton/service/HealthzService.scala
@@ -13,6 +13,10 @@ case class ToFSStatus(status: String)
 case class FromFsStatus(status: String)
 case object GetHealthStatus
 
+object HealthzService {
+  def apply() (implicit context: ActorContext) = new HealthzService()
+}
+
 class HealthzService() (implicit val context: ActorContext, system: ActorSystem) {
   implicit def executionContext = system.dispatcher
 
-- 
GitLab