Skip to content
This repository has been archived by the owner on Feb 19, 2021. It is now read-only.

Commit

Permalink
make internal message serializable (#56)
Browse files Browse the repository at this point in the history
  • Loading branch information
kailuowang committed Jul 30, 2016
1 parent 6345c98 commit 24f2d1b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
Expand Up @@ -54,7 +54,7 @@ class EndpointsRegistryUpdater(registry: EndpointsRegistry) extends Actor with A

case AddDoc(role, doc)
log.info(s"Registering Api Documentation for $role")
updateDoc(Added(sender))(_ + (role Json.stringify(doc)))
updateDoc(Added(sender))(_ + (role doc))

case Remove(role)
removeEndpoint(sender) { endpointDef
Expand Down Expand Up @@ -115,7 +115,7 @@ object EndpointsRegistryUpdater {

case class Add(endpointDef: EndpointDefinition) extends UpdateRequest

case class AddDoc(role: String, doc: JsObject)
case class AddDoc(role: String, doc: String)

case class Remove(role: String) extends UpdateRequest

Expand Down
@@ -1,6 +1,6 @@
package asobu.distributed.gateway

import akka.actor.{Props, ActorLogging, Actor, ActorRef}
import akka.actor._
import akka.cluster.ddata.Replicator._
import asobu.distributed.EndpointsRegistry
import asobu.distributed.gateway.ApiDocumentationRegistry.Retrieve
Expand Down
Expand Up @@ -5,7 +5,7 @@ import akka.cluster.Cluster
import akka.util.Timeout
import asobu.distributed.EndpointsRegistryUpdater.{Added, AddDoc}
import asobu.distributed.{EndpointsRegistryUpdater, EndpointsRegistry}
import play.api.libs.json.JsObject
import play.api.libs.json.{Json, JsObject}
import play.routes.compiler.Route
import akka.pattern.ask
import scala.concurrent.{Future, ExecutionContext}
Expand All @@ -22,14 +22,14 @@ case class ApiDocumentationReporter(registry: EndpointsRegistry)(

lazy val roleO = Cluster(system).selfRoles.headOption

def report(controllers: Seq[Controller])(implicit ec: ExecutionContext): Future[Option[JsObject]] = {
def report(controllers: Seq[Controller])(implicit ec: ExecutionContext): Future[Option[String]] = {
val allRoutes = controllers.flatMap(_.routes)
val addO = for {
role roleO
doc generator(allRoutes)
} yield AddDoc(role, doc)
} yield AddDoc(role, Json.stringify(doc))

addO.fold[Future[Option[JsObject]]](Future.successful(None)) { add
addO.fold[Future[Option[String]]](Future.successful(None)) { add
(clientActor ? add) collect {
case Added(_) addO.map(_.doc)
}
Expand Down

0 comments on commit 24f2d1b

Please sign in to comment.