Hi Justin,

I do something similar.

I define some kind of interface/protocol in on object(in most cases not a 
companion object) like

object MyActorProtocol {
  final case class FindCustomer(id: String)
  sealed trait FindCustomerResponse
  final case class FoundCustomer(customer: Option[Customer]) extends 
FindCustomerResponse
  final case class FindCustomerFailed(id: String, cause: YourWhatever) 
extends FindCustomerResponse
}

Whether I match the response case class or the trait in the handler depends 
on my needs. Sometimes I just match the trait and pass it to a method that 
then can evaluate the result.

Sometimes I even have all methods of a "group" under a  "super-trait" and 
all messages of a protocol under a "mega-trait"

This sometimes helps when you need some kind of "default-handling" when 
your actor switches states and you also listen to other "protocols" like an 
internal protocol of your actor. 


Another thing: 
That way I can also map cast the content of a Future to the trait when 
"asking" an actor and know what I have to expect.


I hope that helped.



Christian

-- 
>>>>>>>>>>      Read the docs: http://akka.io/docs/
>>>>>>>>>>      Check the FAQ: 
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>>      Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to