Code Monkey home page Code Monkey logo

scalikejdbc-streams's Introduction

ScalikeJDBC-streams

Release

It is assumed to be used in batch application. In JDBC, you need to keep connections constantly while subscribing to streaming. Therefore, please reconsider the connection pool setting and always be careful not to exhaust the connection.

Getting Started

supports Scala 2.11.x, 2.12.x

resolvers += "jitpack" at "https://jitpack.io"
libraryDependencies ++= Seq(
  "com.github.yoskhdia" %% "scalikejdbc-streams" % "<latest version>",
  "com.h2database"  %  "h2"                 % "1.4.+",
  "ch.qos.logback"  %  "logback-classic"    % "1.1.+"
)

For the full document of ScalikeJDBC please refer to the following http://scalikejdbc.org/

Example

import scalikejdbc._
import scalikejdbc.streams._

// We recommend that you prepare a ThreadPoolExecutor that generates daemon threads
implicit val executor = AsyncExecutor(scala.concurrent.ExecutionContext.global)

val publisher = DB stream {
  sql"select id from users".map(r => r.int("id")).cursor
}
publisher.subscribe(???)

Please refer to the document on usage of ScalikeJDBC such as connection pool initialization http://scalikejdbc.org/documentation/configuration.html

Note

For MySQL, PostgreSQL, and others, several settings are required to enable CURSOR (Streaming). In ScalikeJDBC-streams, if driverName can be identified, this setting is automatically enabled. Currently only MySQL and PostgreSQL are supported.

import scalikejdbc._
val poolSettings = ConnectionPoolSettings(driverName = "com.mysql.jdbc.Driver")
Class.forName(poolSettings.driverName)
ConnectionPool.singleton("jdbc:mysql://127.0.0.1/scalikejdbc_streams_test", "user", "pass", poolSettings)

With scalikejdbc-config you can easily delegate these settings to application.conf. http://scalikejdbc.org/documentation/configuration.html#scalikejdbc-config

ReactiveStreams TCK

TCK is released in ReactiveStreams. https://github.com/reactive-streams/reactive-streams-jvm/tree/v1.0.0/tck ScalikeJDBC-streams passes PublisherVerification. However, although it is also described in Section Structure of the TCK, Some tests can not construct (meaningful) automatic test. If you have a good idea please send me a PullRequest!

scalikejdbc-streams's People

Contributors

yoskhdia avatar

Watchers

kenji yoshida avatar James Cloos avatar  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.