-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: added serverAddressList as connection option
- Loading branch information
1 parent
5f5c1ab
commit 0c8861a
Showing
11 changed files
with
128 additions
and
119 deletions.
There are no files selected for viewing
43 changes: 43 additions & 0 deletions
43
src/main/scala/dev/mongocamp/driver/mongodb/database/ConfigHelper.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,43 @@ | ||
package dev.mongocamp.driver.mongodb.database | ||
|
||
import com.typesafe.config.{ Config, ConfigFactory } | ||
|
||
trait ConfigHelper { | ||
val conf: Config = ConfigFactory.load() | ||
|
||
def stringConfig(configPath: String, key: String, default: String = ""): Option[String] = { | ||
if (conf.hasPath("%s.%s".format(configPath, key))) { | ||
val str = conf.getString("%s.%s".format(configPath, key)) | ||
if (str.nonEmpty) { | ||
Some(str) | ||
} | ||
else { | ||
None | ||
} | ||
} | ||
else if (default.nonEmpty) { | ||
Some(default) | ||
} | ||
else { | ||
None | ||
} | ||
} | ||
|
||
def intConfig(configPath: String, key: String, default: Int = 0): Int = { | ||
if (conf.hasPath("%s.%s".format(configPath, key))) { | ||
conf.getInt("%s.%s".format(configPath, key)) | ||
} | ||
else { | ||
default | ||
} | ||
} | ||
|
||
def booleanConfig(configPath: String, key: String, default: Boolean = false): Boolean = { | ||
if (conf.hasPath("%s.%s".format(configPath, key))) { | ||
conf.getBoolean("%s.%s".format(configPath, key)) | ||
} | ||
else { | ||
default | ||
} | ||
} | ||
} |
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
1 change: 1 addition & 0 deletions
1
src/main/scala/dev/mongocamp/driver/mongodb/pagination/MongoPagination.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
3 changes: 3 additions & 0 deletions
3
src/main/scala/dev/mongocamp/driver/mongodb/server/H2BackendConfig.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,3 @@ | ||
package dev.mongocamp.driver.mongodb.server | ||
|
||
case class H2BackendConfig(inMemory: Boolean = true, path: Option[String] = None) |
6 changes: 6 additions & 0 deletions
6
src/main/scala/dev/mongocamp/driver/mongodb/server/ServerBackend.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,6 @@ | ||
package dev.mongocamp.driver.mongodb.server | ||
|
||
object ServerBackend extends Enumeration { | ||
type ServerBackend = Value | ||
val Memory, H2 = Value | ||
} |
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
3 changes: 3 additions & 0 deletions
3
src/main/scala/dev/mongocamp/driver/mongodb/sync/MongoSyncException.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,3 @@ | ||
package dev.mongocamp.driver.mongodb.sync | ||
|
||
case class MongoSyncException(message: String) extends Exception(message) |
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
14 changes: 14 additions & 0 deletions
14
src/main/scala/dev/mongocamp/driver/mongodb/sync/MongoSyncResult.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,14 @@ | ||
package dev.mongocamp.driver.mongodb.sync | ||
|
||
import java.util.Date | ||
|
||
case class MongoSyncResult( | ||
collectionName: String, | ||
syncDate: Date = new Date(), | ||
acknowleged: Boolean = false, | ||
synced: Int = -1, | ||
countBefore: Int = -1, | ||
countAfter: Int = -1, | ||
syncTime: Long = -1, | ||
exception: Option[Exception] = None | ||
) |
6 changes: 6 additions & 0 deletions
6
src/main/scala/dev/mongocamp/driver/mongodb/sync/SyncDirection.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,6 @@ | ||
package dev.mongocamp.driver.mongodb.sync | ||
|
||
object SyncDirection extends Enumeration { | ||
type SyncDirection = Value | ||
val SourceToTarget, TargetToSource, TwoWay = Value | ||
} |
6 changes: 6 additions & 0 deletions
6
src/main/scala/dev/mongocamp/driver/mongodb/sync/SyncStrategy.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,6 @@ | ||
package dev.mongocamp.driver.mongodb.sync | ||
|
||
object SyncStrategy extends Enumeration { | ||
type SyncStrategy = Value | ||
val SyncAll = Value | ||
} |