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

Commit

Permalink
Merge pull request #81 from hmrc/BDOG-910
Browse files Browse the repository at this point in the history
BDOG-910: Use  key to lookup default heartbeatFrequencyMS
cjwebb authored Jul 2, 2020

Verified

This commit was signed with the committer’s verified signature.
jorisv Joris Vaillant
2 parents 30f3341 + 2037b8c commit 9875e5b
Showing 2 changed files with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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")
12 changes: 12 additions & 0 deletions src/test/scala/play/modules/reactivemongo/MongoConfigSpec.scala
Original file line number Diff line number Diff line change
@@ -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)
}
}
}

0 comments on commit 9875e5b

Please sign in to comment.