Created
July 27, 2014 23:19
-
-
Save j14159/00b097487976b6486513 to your computer and use it in GitHub Desktop.
This file contains 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
val databaseUrl = "postgresql://some-hostname:5432/db-name" | |
Class.forName("my.sql.database.driver.classname") | |
class BasicJdbcActor(connFac: () => Connection) extends Actor { | |
lazy val conn = connFac() | |
override def preRestart(why: Throwable, msg: Option[Any]): Unit = | |
try { conn.close() } | |
def receive = { | |
case anything => throw new Exception("Where's my implementation?") | |
} | |
} | |
def connFac = () => DriverManager.getConnection(databaseUrl) | |
def makeMeAnActor(sys: ActorSystem): ActorRef = | |
sys.actorOf(Props(new BasicJdbcActor(connFac))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment