-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
38 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
es { | ||
protocol: "http" | ||
host: "localhost" | ||
port: 9200 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package es | ||
|
||
import com.sksamuel.elastic4s.http.ElasticNodeEndpoint | ||
import com.sksamuel.elastic4s.http.ElasticProperties | ||
|
||
object ESConfig { | ||
|
||
case class ElasticNodeProperties(protocol: String, host: String, port: Int) | ||
|
||
case class AppProperties(es: ElasticNodeProperties) | ||
|
||
import pureconfig._ | ||
import pureconfig.generic.auto._ | ||
|
||
private lazy val config = | ||
ConfigSource | ||
.resources("application.conf") | ||
.load[AppProperties] | ||
.getOrElse(throw new IllegalArgumentException("config read error")) | ||
|
||
private lazy val es = config.es | ||
|
||
private lazy val options: Map[String, String] = Map.empty | ||
|
||
private lazy val nodes: Seq[ElasticNodeEndpoint] = Seq(ElasticNodeEndpoint(es.protocol, es.host, es.port, None)) | ||
|
||
// val props: ElasticProperties = ElasticProperties("http://localhost:9200") | ||
lazy val props: ElasticProperties = ElasticProperties(nodes, options) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters