I am re-learning Scala, and I wanted to do a system flow as follows
Routes(Akka-Http) which asks an Actor Model(Akka) which then asks the Database through a Slick Model.
Something like
Route
path("rooms"){
get {
val rooms = (actorRoom ? GetRooms).mapTo[Seq[Room]] //bad code
complete(rooms) //bad code
}
}
ActorRoom
def receive = {
case GetRooms => sender() ! ModelRoom.getRooms()
Slick Model
val rooms = TableQuery[RoomTable]
def getRooms(): Future[Seq[Room]] = rooms.result
My problem is that i am not sure when to resolve the rooms.
Should I do it within the actor? (the route complete does not seem to wait)
Should I do it within the route? (how should i do it?)
Is this approach correct, or the actor is too much?