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

Commit

Permalink
BDOG-910: Use key to lookup default heartbeatFrequencyMS
Browse files Browse the repository at this point in the history
We had trouble rolling out a platform-wide default in app-config-common,
as the configuration currently has some applications using
'Prod.mongodb'. See comments on the JIRA ticket for further description.
  • Loading branch information
cjwebb committed Jul 2, 2020
1 parent 9d7905f commit 2037b8c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
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

0 comments on commit 2037b8c

Please sign in to comment.