Skip to content

Instantly share code, notes, and snippets.

@j14159
Last active August 29, 2015 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save j14159/6aee8831ffb10747f226 to your computer and use it in GitHub Desktop.
Save j14159/6aee8831ffb10747f226 to your computer and use it in GitHub Desktop.
case class Person(name: String, email: String)
case class PersonById(id: Int)
class PersonDao(cf: () => Connection) extends Actor {
lazy val conn = cf()
override def preRestart(why: Throwable, msg: Option[Any]): Unit =
try { conn.close() }
def receive = {
case Person(n, e) =>
//call insert function with above connection
sender ! 1 // mock person ID
case PersonById(id) =>
//get person from connection above
sender ! Person("name", "email") // mock
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment