Last active
December 31, 2015 21:59
-
-
Save privateblue/8050104 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// kinja-service library | |
class SsoService extends ApiService { | |
def authorByToken(token: String): Author = { | |
lookupAuthorInDatabase(token) | |
} | |
} | |
case class AuthorByToken(token: String) | |
class InvitesService extends Service { | |
def invite(token: String, invitee: Author, ssoActor: ActorRef): Unit = { | |
val inviter = Await.result( | |
ssoActor ? AuthorByToken(token), | |
1 seconds | |
) | |
saveInvitationToDatabase(inviter, invitee) | |
} | |
} | |
case class InviteMessage(token: String, invitee: Author) | |
// kinja-core application | |
object SsoService extends service.SsoService | |
object InvitesService extends service.InvitesService | |
import service.model.AuthorByToken | |
class SsoActor extends Actor { | |
def receive = { | |
case AuthorByToken(token) => sender ! SsoService.authorByToken(token) | |
} | |
} | |
val ssoActor = akka.actor.ActorSystem("kinja-core").actorOf(Props(classOf[SsoActor], "sso-actor")) | |
import service.model.InviteMessage | |
class InvitesActor extends Actor { | |
def receive = { | |
case InviteMessage(token, invitee) => InvitesService.invite(token, invitee, ssoActor) | |
} | |
} | |
val invitesActor = akka.actor.ActorSystem("kinja-core").actorOf(Props(classOf[InvitesActor], "invites-actor")) | |
// kinja-mantle application | |
import service.model.InviteMessage | |
object InvitesApiClient { | |
def invite(token: String, invitee: Author): Unit = { | |
val invitesService = context.actorSelection("akka.tcp://kinja-core@localhost:2552/user/invites-actor") | |
invitesService ! InviteMessage(token, invitee) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment