Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[reactive-mongo] Acolyte DSL (connection & query handler)
- Loading branch information
cchantep
committed
Aug 20, 2014
1 parent
b1bcb6e
commit f8f7cbe
Showing
11 changed files
with
119 additions
and
33 deletions.
There are no files selected for viewing
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
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
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
29 changes: 29 additions & 0 deletions
29
reactive-mongo/src/main/scala/acolyte/reactivemongo/AcolyteDSL.scala
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package acolyte.reactivemongo | ||
|
||
import reactivemongo.api.MongoDriver | ||
import reactivemongo.bson.BSONDocument | ||
|
||
/** | ||
* Acolyte DSL for ReactiveMongo. | ||
*/ | ||
object AcolyteDSL { | ||
|
||
/** | ||
* Returns Mongo driver configured with Acolyte handlers. | ||
* | ||
* @param param handler Connection handler | ||
*/ | ||
def driver(handler: ConnectionHandler): MongoDriver = | ||
new MongoDriver(Some(Akka.actorSystem(handler))) | ||
|
||
/** | ||
* Creates an empty handler. | ||
* | ||
* {{{ | ||
* import acolyte.reactivemongo.AcolyteDSL.{ connection, handleStatement } | ||
* | ||
* connection { handleStatement } | ||
* }}} | ||
*/ | ||
def handleStatement: ConnectionHandler = ??? | ||
} |
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
21 changes: 21 additions & 0 deletions
21
reactive-mongo/src/main/scala/acolyte/reactivemongo/ConnectionHandler.scala
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package acolyte.reactivemongo | ||
|
||
/** Connection handler */ | ||
case class ConnectionHandler(queryHandler: QueryHandler) { | ||
|
||
/** | ||
* Creates a copy of this connection handler, | ||
* with given query `handler` appended. | ||
*/ | ||
def withQueryHandler(handler: QueryHandler): ConnectionHandler = | ||
copy({ q ⇒ queryHandler(q).orElse(handler(q)) }) | ||
|
||
} | ||
|
||
/** Companion object for connection handler. */ | ||
object ConnectionHandler { | ||
|
||
// TODO | ||
lazy val empty: ConnectionHandler = ConnectionHandler(_ ⇒ ???) | ||
|
||
} |
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
11 changes: 11 additions & 0 deletions
11
reactive-mongo/src/main/scala/acolyte/reactivemongo/package.scala
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package acolyte | ||
|
||
package object reactivemongo { | ||
import _root_.reactivemongo.bson.BSONDocument | ||
|
||
/** | ||
* Mongo query handler. | ||
* If returns `None`, next handler is called. | ||
*/ | ||
type QueryHandler = Query ⇒ Option[Seq[BSONDocument]] | ||
} |
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
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
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