This project contains a module to use kuzminki-ec with Play Framework. It also contains integration with the Play Json library. Take a look at the kuzminki-play-demo for an example of usage.
This version is for Play 3. If you are using Play 2.9 with Akka, you can use version 0.9.3
// available for Scala 2.13 and Scala 3
libraryDependencies += "io.github.karimagnusson" %% "kuzminki-play" % "0.9.5"
play.modules.enabled += "kuzminki.pekko.play.module.KuzminkiModule"
kuzminki = {
db = "<DB_NAME>"
user = "<USER>"
password = "<PASS>"
host = "localhost"
port = 5432
maxPoolSize = 10
minPoolSize = 3
}
@Singleton
class SomeController @Inject()(
val controllerComponents: ControllerComponents
)(implicit ec: ExecutionContext,
db: Kuzminki) extends BaseController
with PlayJson { // implicit conversions for Play Json
Support fo multiple databases. Database named 'default' will not be named.
play.modules.enabled += "kuzminki.pekko.play.module.KuzminkiMultiModule"
kuzminki-multi = {
default = {
db = "some_db"
user = "user"
password = "pass"
}
other = {
db = "other_db"
user = "user"
password = "pass"
}
}
@Singleton
class SomeController @Inject()(
val controllerComponents: ControllerComponents,
@Named("other") otherDb: Kuzminki
)(implicit ec: ExecutionContext,
db: Kuzminki) extends BaseController // default database
with PlayJson { // implicit conversions for Play Json
Master / slave configuration provides one api where all SELECT queries will go to the slave and all others to the master. If a dispatcher is defined it should be under kuzminki-split.
play.modules.enabled += "kuzminki.pekko.play.module.KuzminkiSplitProvider"
kuzminki-split = {
master = {
db = "master_db"
user = "user"
password = "pass"
}
slave = {
db = "slave_db"
user = "user"
password = "pass"
}
}
@Singleton
class SomeController @Inject()(
val controllerComponents: ControllerComponents
)(implicit ec: ExecutionContext,
db: Kuzminki) extends BaseController
with PlayJson { // implicit conversions for Play Json