Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ElasticSearch: Replace RestClient with Akka HTTP client (#2347)
- Loading branch information
Marc Rooding
committed
Nov 13, 2020
1 parent
4fdf171
commit caa01ba
Showing
31 changed files
with
2,844 additions
and
1,698 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
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 @@ | ||
ProblemFilters.exclude[Problem]("akka.stream.alpakka.elasticsearch.*") |
37 changes: 37 additions & 0 deletions
37
...ch/src/main/scala/akka/stream/alpakka/elasticsearch/ElasticsearchConnectionSettings.scala
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,37 @@ | ||
/* | ||
* Copyright (C) 2016-2020 Lightbend Inc. <https://www.lightbend.com> | ||
*/ | ||
|
||
package akka.stream.alpakka.elasticsearch | ||
|
||
final class ElasticsearchConnectionSettings private ( | ||
val baseUrl: String, | ||
val username: Option[String], | ||
val password: Option[String] | ||
) { | ||
|
||
def withBaseUrl(value: String): ElasticsearchConnectionSettings = copy(baseUrl = value) | ||
|
||
def withCredentials(username: String, password: String): ElasticsearchConnectionSettings = | ||
copy(username = Option(username), password = Option(password)) | ||
|
||
def hasCredentialsDefined: Boolean = username.isDefined && password.isDefined | ||
|
||
def copy(baseUrl: String = baseUrl, | ||
username: Option[String] = username, | ||
password: Option[String] = password): ElasticsearchConnectionSettings = | ||
new ElasticsearchConnectionSettings(baseUrl = baseUrl, username = username, password = password) | ||
|
||
override def toString = | ||
s"""ElasticsearchConnectionSettings(baseUrl=$baseUrl,username=$username,password=${password.fold("")(_ => "***")})""" | ||
} | ||
|
||
object ElasticsearchConnectionSettings { | ||
|
||
/** Scala API */ | ||
def apply(baseUrl: String): ElasticsearchConnectionSettings = new ElasticsearchConnectionSettings(baseUrl, None, None) | ||
|
||
/** Java API */ | ||
def create(baseUrl: String): ElasticsearchConnectionSettings = | ||
new ElasticsearchConnectionSettings(baseUrl, None, None) | ||
} |
25 changes: 25 additions & 0 deletions
25
elasticsearch/src/main/scala/akka/stream/alpakka/elasticsearch/ElasticsearchParams.scala
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,25 @@ | ||
/* | ||
* Copyright (C) 2016-2020 Lightbend Inc. <https://www.lightbend.com> | ||
*/ | ||
|
||
package akka.stream.alpakka.elasticsearch | ||
|
||
final class ElasticsearchParams private (val indexName: String, val typeName: Option[String]) { | ||
override def toString = | ||
s"""ElasticsearchParams(indexName=$indexName,typeName=$typeName)""" | ||
} | ||
|
||
object ElasticsearchParams { | ||
def V7(indexName: String): ElasticsearchParams = { | ||
require(indexName != null, "You must define an index name") | ||
|
||
new ElasticsearchParams(indexName, None) | ||
} | ||
|
||
def V5(indexName: String, typeName: String): ElasticsearchParams = { | ||
require(indexName != null, "You must define an index name") | ||
require(typeName != null && typeName.trim.nonEmpty, "You must define a type name for ElasticSearch API version V5") | ||
|
||
new ElasticsearchParams(indexName, Some(typeName)) | ||
} | ||
} |
Oops, something went wrong.