Skip to content

Commit

Permalink
[PS] TAV-594 - Use new RDS db for ABP searches if enabled in config
Browse files Browse the repository at this point in the history
  • Loading branch information
beyond-code-github committed Nov 29, 2022
1 parent a0b3149 commit a5e69b7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
12 changes: 11 additions & 1 deletion app/Module.scala
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,16 @@ class Module(environment: Environment, configuration: Configuration) extends Abs
inMemoryABPAddressRepository: InMemoryABPAddressRepository): ABPAddressRepository = {

val dbEnabled = isDbEnabled(configHelper)
val cipPaasDbEnabled = isCipPaasDbEnabled(configHelper)

val repository: ABPAddressRepository = if (dbEnabled) {
val transactor = new TransactorProvider(configuration, applicationLifecycle).get(executionContext)
val transactor = if (cipPaasDbEnabled) {
new TransactorProvider(configuration, applicationLifecycle, "cip-address-lookup-rds").get(executionContext)
}
else {
new TransactorProvider(configuration, applicationLifecycle).get(executionContext)
}

new PostgresABPAddressRepository(transactor, rdsQueryConfig)
} else {
inMemoryABPAddressRepository
Expand Down Expand Up @@ -98,6 +105,9 @@ class Module(environment: Environment, configuration: Configuration) extends Abs
private def isDbEnabled(configHelper: ConfigHelper): Boolean =
configHelper.getConfigString("address-lookup-rds.enabled").getOrElse("false").toBoolean

private def isCipPaasDbEnabled(configHelper: ConfigHelper): Boolean =
configHelper.getConfigString("cip-address-lookup-rds.enabled").getOrElse("false").toBoolean

@Provides
@Singleton
def providesReferenceData(configHelper: ConfigHelper): ReferenceData =
Expand Down
1 change: 0 additions & 1 deletion app/repositories/CIPPostgresABPAddressRepository.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package repositories

import cats.effect.IO
import config.Capitalisation._
import doobie.Transactor
import doobie.implicits._
import play.api.Logger
Expand Down

0 comments on commit a5e69b7

Please sign in to comment.