Last active
December 31, 2015 21:59
-
-
Save privateblue/8050229 to your computer and use it in GitHub Desktop.
This file contains hidden or 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) | |
} | |
} | |
trait SsoServiceContract { | |
abstract class AuthorByToken { | |
def apply(token: String): Author | |
} | |
} | |
class InvitesService extends Service { | |
def invite(token: String, invitee: Author, ssoServiceCallContract: SsoServiceContract#AuthorByToken): Unit = { | |
val inviter = ssoServiceCallContract.apply(token) | |
saveInvitationToDatabase(inviter, invitee) | |
} | |
} | |
case class InviteMessage(token: String, invitee: Author) | |
// kinja-core application | |
object SsoService extends service.SsoService | |
object SsoServiceContract extends service.SsoServiceContract { | |
class AuthorByTokenImpl extends AuthorByToken { | |
def apply(token: String) = SsoService.authorByToken(token) | |
} | |
} | |
object InvitesService extends service.InvitesService | |
import service.model.InviteMessage | |
class InvitesActor extends Actor { | |
def receive = { | |
case InviteMessage(token, invitee) => InvitesService.invite(token, invitee, SsoServiceContract.AuthorByTokenImpl) | |
} | |
} | |
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