Hi,
I want to implement I was looking at this example taken from typesafe activator
(spray-actor-per-request) class RestRouting extends HttpService with Actor with PerRequestCreator {
implicit def actorRefFactory: ActorContext = context
def receive = runRoute(route)
val petService = context.actorOf(Props[PetClient])
val ownerService = context.actorOf(Props[OwnerClient])
val route = {
get {
path("pets") {
parameters('names) { names =>
petsWithOwner {
GetPetsWithOwners(names.split(',').toList)
}
}
}
}
}
def petsWithOwner(message : RestMessage): Route =
ctx => perRequest(ctx, Props(new GetPetsWithOwnersActor(petService, ownerService)), message)
}
and I wonder if this is the best parctice to implement the actors creation :
ctx => perRequest(ctx, Props(new GetPetsWithOwnersActor(petService, ownerService)), message)because I saw at the akka documentation
this warning regarding creating actor within an actor :
val props2 = Props(new ActorWithArgs("arg")) // careful, see belowalso if we define an actor within an actor
val ownerService = context.actorOf(Props[OwnerClient])
how can it be tested ?
Just to make things clear - I am not criticizing, I am just trying to learn the best practice of implementation specially as I see the typesafe activator as educational source
Best wishes
Avi