Skip to content
This repository has been archived by the owner on Mar 15, 2021. It is now read-only.

Commit

Permalink
Merge pull request #3 from xnejp03/enable_config_in_root
Browse files Browse the repository at this point in the history
Enable to store the plugin's config in the config root
  • Loading branch information
duncancrawford committed Sep 8, 2015
2 parents f922ddc + a14c78c commit bb373cc
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
27 changes: 15 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,26 @@ This plugin reads connection properties from the `application.conf` and gives yo

#### Add this to your conf/application.conf

The plugin will look for the mongo config under a root of the `Application#mode`. If no configuration is found for the current application mode then the fallback is `Mode.Dev`
The plugin will look for the mongo config under:
- the config root, then if not found
- the root of the `Application#mode`, then if not found
- the root of the `Application#Dev`

```
Dev {
mongodb {
uri = "mongodb://username:password@localhost:27017/your_db_name"
channels = 5
failoverStrategy = {
initialDelayMsecs = 100
retries = 10
delay = {
function = fibonacci
factor = 1
}
mongodb {
uri = "mongodb://username:password@localhost:27017/your_db_name"
channels = 5
failoverStrategy = {
initialDelayMsecs = 100
retries = 10
delay = {
function = fibonacci
factor = 1
}
}
}
```

### Installing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,10 @@ object ReactiveMongoPlugin {

private [reactivemongo] def parseConf(app: Application): MongoConnector = {

val mongoConfig = app.configuration.getConfig(s"${app.mode}.mongodb")
val mongoConfig = app.configuration.getConfig("mongodb")
.getOrElse(app.configuration.getConfig(s"${app.mode}.mongodb")
.getOrElse(app.configuration.getConfig(s"${Mode.Dev}.mongodb")
.getOrElse(throw new Exception("The application does not contain required mongodb configuration")))
.getOrElse(throw new Exception("The application does not contain required mongodb configuration"))))

mongoConfig.getString("uri") match {
case Some(uri) => {
Expand Down

0 comments on commit bb373cc

Please sign in to comment.