diff --git a/common/lambda/src/main/scala/weco/lambda/ElasticBuilder.scala b/common/lambda/src/main/scala/weco/lambda/ElasticBuilder.scala deleted file mode 100644 index 3edae1b6f0..0000000000 --- a/common/lambda/src/main/scala/weco/lambda/ElasticBuilder.scala +++ /dev/null @@ -1,93 +0,0 @@ -package weco.lambda - -import com.sksamuel.elastic4s.ElasticClient -import com.typesafe.config.Config -import weco.elasticsearch.ElasticClientBuilder - -sealed trait ElasticConfig { - val host: String - val port: Int - val protocol: String -} - -case class ElasticConfigUsernamePassword( - host: String, - port: Int, - protocol: String, - username: String, - password: String -) extends ElasticConfig - -case class ElasticConfigApiKey( - host: String, - port: Int, - protocol: String, - apiKey: String -) extends ElasticConfig - -// This should be moved up to scala-libs, it's copied from there! - -object ElasticBuilder { - import weco.typesafe.config.builders.EnrichConfig._ - - def buildElasticClientConfig( - config: Config, - namespace: String = "" - ): ElasticConfig = { - val hostname = config.requireString(s"es.$namespace.host") - val port = config - .getIntOption(s"es.$namespace.port") - .getOrElse(9200) - val protocol = config - .getStringOption(s"es.$namespace.protocol") - .getOrElse("http") - - ( - config.getStringOption(s"es.$namespace.username"), - config.getStringOption(s"es.$namespace.password"), - config.getStringOption(s"es.$namespace.apikey") - ) match { - case (Some(username), Some(password), None) => - ElasticConfigUsernamePassword( - hostname, - port, - protocol, - username, - password - ) - // Use an API key if specified, even if username/password are also present - case (_, _, Some(apiKey)) => - ElasticConfigApiKey(hostname, port, protocol, apiKey) - case _ => - throw new Throwable( - s"You must specify username and password, or apikey, in the 'es.$namespace' config" - ) - } - } - - def buildElasticClient(config: ElasticConfig): ElasticClient = - config match { - case ElasticConfigUsernamePassword( - hostname, - port, - protocol, - username, - password - ) => - ElasticClientBuilder.create( - hostname, - port, - protocol, - username, - password - ) - case ElasticConfigApiKey(hostname, port, protocol, apiKey) => - ElasticClientBuilder.create(hostname, port, protocol, apiKey) - } - - def buildElasticClient( - config: Config, - namespace: String = "" - ): ElasticClient = - buildElasticClient(buildElasticClientConfig(config, namespace)) -} diff --git a/pipeline/relation_embedder/relation_embedder/src/main/scala/weco/pipeline/relation_embedder/BatchProcessor.scala b/pipeline/relation_embedder/relation_embedder/src/main/scala/weco/pipeline/relation_embedder/BatchProcessor.scala index 1dc269d528..a0a440b6b7 100644 --- a/pipeline/relation_embedder/relation_embedder/src/main/scala/weco/pipeline/relation_embedder/BatchProcessor.scala +++ b/pipeline/relation_embedder/relation_embedder/src/main/scala/weco/pipeline/relation_embedder/BatchProcessor.scala @@ -18,7 +18,8 @@ import weco.pipeline_storage.elastic.ElasticIndexer import scala.concurrent.{ExecutionContext, Future} import scala.util.{Failure, Success} import weco.catalogue.internal_model.Implicits._ -import weco.lambda.{Downstream, ElasticBuilder} +import weco.elasticsearch.typesafe.ElasticBuilder +import weco.lambda.Downstream import weco.pipeline.relation_embedder.lib.RelationEmbedderConfig class BatchProcessor( diff --git a/pipeline/relation_embedder/relation_embedder/src/main/scala/weco/pipeline/relation_embedder/lib/RelationEmbedderConfig.scala b/pipeline/relation_embedder/relation_embedder/src/main/scala/weco/pipeline/relation_embedder/lib/RelationEmbedderConfig.scala index 4e01b39243..9926af9592 100644 --- a/pipeline/relation_embedder/relation_embedder/src/main/scala/weco/pipeline/relation_embedder/lib/RelationEmbedderConfig.scala +++ b/pipeline/relation_embedder/relation_embedder/src/main/scala/weco/pipeline/relation_embedder/lib/RelationEmbedderConfig.scala @@ -1,7 +1,8 @@ package weco.pipeline.relation_embedder.lib import com.typesafe.config.Config -import weco.lambda.ElasticBuilder.buildElasticClientConfig +import weco.elasticsearch.typesafe.ElasticBuilder.buildElasticClientConfig +import weco.elasticsearch.typesafe.ElasticConfig import weco.lambda._ import weco.messaging.typesafe.SNSBuilder.buildSNSConfig diff --git a/project/Dependencies.scala b/project/Dependencies.scala index 5dfd6cea77..08d32d9595 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -1,16 +1,17 @@ import sbt._ import scala.language.reflectiveCalls object WellcomeDependencies { + lazy val defaultVersion = "32.43.4" lazy val versions = new { - val typesafe = "32.43.2" - val fixtures = "32.43.2" - val http = "32.43.2" - val json = "32.43.2" - val messaging = "32.43.2" - val monitoring = "32.43.2" - val storage = "32.43.2" - val elasticsearch = "32.43.2" - val sierra = "32.43.2" + val typesafe = defaultVersion + val fixtures = defaultVersion + val http = defaultVersion + val json = defaultVersion + val messaging = defaultVersion + val monitoring = defaultVersion + val storage = defaultVersion + val elasticsearch = defaultVersion + val sierra = defaultVersion } val jsonLibrary: Seq[ModuleID] = Seq(