Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor Bulk response #210

Merged
merged 1 commit into from
May 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,12 @@ sealed trait Item {
def error: Option[Error]
}

private[elasticsearch] object Item {
implicit val decoder: JsonDecoder[Item] = DeriveJsonDecoder.gen[Item]
}

@jsonHint("create")
final case class Create private[elasticsearch] (
final case class CreateBulkResponse private[elasticsearch] (
@jsonField("_index")
index: String,
@jsonField("_id")
Expand All @@ -43,12 +47,12 @@ final case class Create private[elasticsearch] (
error: Option[Error]
) extends Item

private[elasticsearch] object Create {
implicit val decoder: JsonDecoder[Create] = DeriveJsonDecoder.gen[Create]
private[elasticsearch] object CreateBulkResponse {
implicit val decoder: JsonDecoder[CreateBulkResponse] = DeriveJsonDecoder.gen[CreateBulkResponse]
}

@jsonHint("delete")
final case class Delete private[elasticsearch] (
final case class DeleteBulkResponse private[elasticsearch] (
@jsonField("_index")
index: String,
@jsonField("_id")
Expand All @@ -62,12 +66,12 @@ final case class Delete private[elasticsearch] (
error: Option[Error]
) extends Item

private[elasticsearch] object Delete {
implicit val decoder: JsonDecoder[Delete] = DeriveJsonDecoder.gen[Delete]
private[elasticsearch] object DeleteBulkResponse {
implicit val decoder: JsonDecoder[DeleteBulkResponse] = DeriveJsonDecoder.gen[DeleteBulkResponse]
}

@jsonHint("index")
final case class Index private[elasticsearch] (
final case class IndexBulkResponse private[elasticsearch] (
@jsonField("_index")
index: String,
@jsonField("_id")
Expand All @@ -81,12 +85,12 @@ final case class Index private[elasticsearch] (
error: Option[Error]
) extends Item

private[elasticsearch] object Index {
implicit val decoder: JsonDecoder[Index] = DeriveJsonDecoder.gen[Index]
private[elasticsearch] object IndexBulkResponse {
implicit val decoder: JsonDecoder[IndexBulkResponse] = DeriveJsonDecoder.gen[IndexBulkResponse]
}

@jsonHint("update")
final case class Update private[elasticsearch] (
final case class UpdateBulkResponse private[elasticsearch] (
@jsonField("_index")
index: String,
@jsonField("_id")
Expand All @@ -100,10 +104,6 @@ final case class Update private[elasticsearch] (
error: Option[Error]
) extends Item

private[elasticsearch] object Update {
implicit val decoder: JsonDecoder[Update] = DeriveJsonDecoder.gen[Update]
}

private[elasticsearch] object Item {
implicit val decoder: JsonDecoder[Item] = DeriveJsonDecoder.gen[Item]
private[elasticsearch] object UpdateBulkResponse {
implicit val decoder: JsonDecoder[UpdateBulkResponse] = DeriveJsonDecoder.gen[UpdateBulkResponse]
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import zio.elasticsearch.domain.TestDocument
import zio.elasticsearch.executor.Executor
import zio.elasticsearch.executor.response.{
BulkResponse,
Create,
CreateBulkResponse,
Shards,
TermsAggregationBucket,
TermsAggregationResponse
Expand Down Expand Up @@ -59,7 +59,7 @@ object HttpElasticExecutorSpec extends SttpBackendStubSpec {
took = 3,
errors = false,
items = List(
Create(
CreateBulkResponse(
index = "repositories",
id = "123",
version = Some(1),
Expand Down