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

Commit 2037b8c

Browse files
committed
BDOG-910: Use key to lookup default heartbeatFrequencyMS
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.
1 parent 9d7905f commit 2037b8c

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/main/scala/play/modules/reactivemongo/MongoConfig.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ class MongoConfig(
6464

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

6869
private lazy val mongoConfig: Configuration = configuration
6970
.getOptional[Configuration]("mongodb")

src/test/scala/play/modules/reactivemongo/MongoConfigSpec.scala

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,18 @@ class MongoConfigSpec extends WordSpec with MockFactory with PropertyChecks {
117117
val value = mongoConfig(s"$mongodbConfigKey.defaultHeartbeatFrequencyMS" -> defaultHeartbeatFrequencyMS).defaultHeartbeatFrequencyMS
118118
value shouldBe Some(defaultHeartbeatFrequencyMS)
119119
}
120+
121+
s"ignore 'platform.mongodb.defaultHeartbeatFrequencyMS' if $mongodbConfigKey.defaultHeartbeatFrequencyMS specified" in new Setup {
122+
val defaultValue = 999
123+
val value = mongoConfig("platform.mongodb.defaultHeartbeatFrequencyMS" -> defaultValue, s"$mongodbConfigKey.defaultHeartbeatFrequencyMS" -> defaultHeartbeatFrequencyMS).defaultHeartbeatFrequencyMS
124+
value shouldBe Some(defaultHeartbeatFrequencyMS)
125+
}
126+
127+
s"fallback to 'platform.mongodb.defaultHeartbeatFrequencyMS' if $mongodbConfigKey.defaultHeartbeatFrequencyMS not specified" in new Setup {
128+
val defaultValue = 999
129+
val value = mongoConfig("platform.mongodb.defaultHeartbeatFrequencyMS" -> defaultValue, s"$mongodbConfigKey.uri" -> "something").defaultHeartbeatFrequencyMS
130+
value shouldBe Some(defaultValue)
131+
}
120132
}
121133
}
122134

0 commit comments

Comments
 (0)