Skip to content
This repository has been archived by the owner on Nov 18, 2024. It is now read-only.

BDOG-910: Use key to lookup default heartbeatFrequencyMS #81

Merged
merged 1 commit into from
Jul 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class MongoConfig(

lazy val defaultHeartbeatFrequencyMS: Option[Int] =
mongoConfig.getOptional[Int]("defaultHeartbeatFrequencyMS")
.orElse(configuration.getOptional[Int]("platform.mongodb.defaultHeartbeatFrequencyMS")) // see BDOG-910 comments

private lazy val mongoConfig: Configuration = configuration
.getOptional[Configuration]("mongodb")
Expand Down
12 changes: 12 additions & 0 deletions src/test/scala/play/modules/reactivemongo/MongoConfigSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,18 @@ class MongoConfigSpec extends WordSpec with MockFactory with PropertyChecks {
val value = mongoConfig(s"$mongodbConfigKey.defaultHeartbeatFrequencyMS" -> defaultHeartbeatFrequencyMS).defaultHeartbeatFrequencyMS
value shouldBe Some(defaultHeartbeatFrequencyMS)
}

s"ignore 'platform.mongodb.defaultHeartbeatFrequencyMS' if $mongodbConfigKey.defaultHeartbeatFrequencyMS specified" in new Setup {
val defaultValue = 999
val value = mongoConfig("platform.mongodb.defaultHeartbeatFrequencyMS" -> defaultValue, s"$mongodbConfigKey.defaultHeartbeatFrequencyMS" -> defaultHeartbeatFrequencyMS).defaultHeartbeatFrequencyMS
value shouldBe Some(defaultHeartbeatFrequencyMS)
}

s"fallback to 'platform.mongodb.defaultHeartbeatFrequencyMS' if $mongodbConfigKey.defaultHeartbeatFrequencyMS not specified" in new Setup {
val defaultValue = 999
val value = mongoConfig("platform.mongodb.defaultHeartbeatFrequencyMS" -> defaultValue, s"$mongodbConfigKey.uri" -> "something").defaultHeartbeatFrequencyMS
value shouldBe Some(defaultValue)
}
}
}

Expand Down