Skip to content
Permalink
Browse files

[reactivemongo] Upgrade ReactiveMongo to 0.16.0 (#86)

  • Loading branch information...
cchantep committed Aug 4, 2018
1 parent a8cc52c commit d81609665798b1c962233f588d0095f49ea33890
@@ -39,6 +39,8 @@ crossScalaVersions in ThisBuild := Seq(
"2.10.7", "2.11.12", (scalaVersion in ThisBuild).value
)

resolvers in ThisBuild += Resolver.sonatypeRepo("snapshots")

//
val scalacPlugin = ScalacPlugin.project

@@ -1,6 +1,6 @@
package acolyte.reactivemongo

import scala.concurrent.{ ExecutionContext, Future }
import scala.concurrent.{ Await, ExecutionContext, Future }

import reactivemongo.api.{ MongoConnection, MongoDriver }
import play.modules.reactivemongo.ReactiveMongoApi
@@ -11,6 +11,7 @@ object PlayReactiveMongoDSL {
* @param con the MongoDB connection
*/
def mongoApi(drv: MongoDriver, con: MongoConnection)(implicit ec: ExecutionContext): ReactiveMongoApi = new ReactiveMongoApi {
import scala.concurrent.duration._
import reactivemongo.api._, gridfs._
import reactivemongo.play.json._
import reactivemongo.play.json.collection._
@@ -23,9 +24,7 @@ object PlayReactiveMongoDSL {
def asyncGridFS: Future[GridFS[JSONSerializationPack.type]] =
database.map(GridFS[JSONSerializationPack.type](_))

@deprecated("Use [[database]]", "1.0.45")
def db: DefaultDB = connection.db("acolyte")

def gridFS = GridFS[JSONSerializationPack.type](db)
def gridFS = Await.result(
database.map(GridFS[JSONSerializationPack.type](_)), 10.seconds)
}
}
@@ -13,32 +13,14 @@ class ReactiveMongo(scalacPlugin: Project) { self =>
lazy val generatedClassDirectory = settingKey[File](
"Directory where classes get generated")

val reactiveMongoVer = "0.15.0"
val reactiveMongoVer = "0.16.0"

lazy val project =
Project(id = "reactive-mongo", base = file("reactive-mongo")).
settings(formatSettings).settings(
name := "reactive-mongo",
fork in Test := true,
javacOptions in Test ++= Seq("-Xlint:unchecked", "-Xlint:deprecation"),
/*scalacOptions ++= {
val v = (version in ThisBuild).value
val sv = (scalaVersion in ThisBuild).value
val b = (baseDirectory in (scalacPlugin, Compile)).value
val n = (name in (scalacPlugin, Compile)).value
val msv = {
if (sv startsWith "2.10") "2.10"
else if (sv startsWith "2.11") "2.11"
else if (sv startsWith "2.12") "2.12"
else sv
}
val td = b / "target" / s"scala-$msv"
val j = td / s"${n}_${msv}-$v.jar"
Seq("-feature", "-deprecation", s"-Xplugin:${j.getAbsolutePath}")
},*/
resolvers ++= reactiveResolvers,
libraryDependencies ++= Seq(
"org.reactivemongo" %% "reactivemongo" % reactiveMongoVer % "provided",
@@ -79,9 +61,13 @@ class ReactiveMongo(scalacPlugin: Project) { self =>
"2.5.13" -> "play25"
}

val playRmVer = reactiveMongoVer.span(_ != '-') match {
case (v, m) => s"${v}-${playVar}${m}"
}

Seq(
"com.typesafe.play" %% "play" % playVer % Provided,
"org.reactivemongo" %% "play2-reactivemongo" % s"${reactiveMongoVer}-${playVar}" % Provided,
"org.reactivemongo" %% "play2-reactivemongo" % playRmVer % Provided,
"org.specs2" %% "specs2-core" % specsVer.value % Test
)
}
@@ -7,6 +7,7 @@ import reactivemongo.bson.{ BSONArray, BSONDocument, BSONString, BSONValue }
import reactivemongo.io.netty.channel.{ ChannelId, DefaultChannelId }
import reactivemongo.core.actors.{
Close,
Closed,
ExpectingResponse,
CheckedWriteRequestExpectingResponse CheckedWriteRequestExResp,
PrimaryAvailable,
@@ -25,7 +26,7 @@ import reactivemongo.core.nodeset.ProtocolMetadata
private[reactivemongo] class Actor(handler: ConnectionHandler)
extends reactivemongo.core.actors.MongoDBSystem {

import reactivemongo.core.nodeset.{ Authenticate, ChannelFactory, Connection }
import reactivemongo.core.nodeset.{ Authenticate, Connection }

lazy val initialAuthenticates = Seq.empty[Authenticate]

@@ -39,7 +40,7 @@ private[reactivemongo] class Actor(handler: ConnectionHandler)

protected def sendAuthenticate(connection: Connection, authentication: Authenticate): Connection = connection

protected def newChannelFactory(effect: Unit): ChannelFactory =
protected def newChannelFactory(effect: Unit) =
reactivemongo.acolyte.channelFactory(supervisor, name, options)

private def handleWrite(chanId: ChannelId, op: WriteOp, req: Request): Option[Response] = Try(handler.writeHandler(chanId, op, req)) match {
@@ -147,10 +148,13 @@ private[reactivemongo] class Actor(handler: ConnectionHandler)
sender ! SetAvailable(ProtocolMetadata.Default)
}

case Close postStop()
case Close | Close(_) {
sender ! Closed
postStop()
}

case _ /*msg */
//println(s"message = $msg")
case msg
println(s"message = $msg")

//next forward msg
()
@@ -31,7 +31,7 @@ object DriverManager {
override lazy val toString = s"DriverManager(timeout = $timeout)"
}

implicit val Default: DriverManager = new Default(2.seconds)
implicit val Default: DriverManager = new Default(5.seconds)

def withTimeout(timeout: FiniteDuration): DriverManager =
new Default(timeout)
@@ -63,6 +63,9 @@ object ConnectionManager {
implicit object HandlerConnectionManager
extends ConnectionManager[ConnectionHandler] {

import scala.concurrent.Await
import scala.concurrent.duration._

def open(driver: MongoDriver, handler: ConnectionHandler) = {
val sys = driver.system
val actorRef = sys.actorOf(Props(classOf[Actor], handler))
@@ -75,10 +78,11 @@ object ConnectionManager {

/** Releases connection if necessary. */
def releaseIfNecessary(connection: MongoConnection): Boolean = try {
connection.close()
Await.result(connection.askClose()(10.seconds), 10.seconds)
true
} catch {
case e: Throwable
println("_here")
e.printStackTrace()
false
}
@@ -1,6 +1,6 @@
package acolyte.reactivemongo

import scala.concurrent.{ ExecutionContext, Future }
import scala.concurrent.ExecutionContext

import reactivemongo.api.{ MongoConnection, MongoDriver }

@@ -1,6 +1,6 @@
package acolyte.reactivemongo

import scala.concurrent.{ ExecutionContext, Future }
import scala.concurrent.ExecutionContext

import reactivemongo.api.{ MongoConnection, MongoDriver }

0 comments on commit d816096

Please sign in to comment.
You can’t perform that action at this time.