Giter VIP home page Giter VIP logo

kuzminki-play's Introduction

Twitter URL

kuzminki-play

About

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

Sbt

// available for Scala 2.13 and Scala 3
libraryDependencies += "io.github.karimagnusson" %% "kuzminki-play" % "0.9.5"

Configuration

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

Multiple databases

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

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

kuzminki-play's People

Contributors

karimagnusson avatar

Stargazers

He-Pin(kerr) avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.