Skip to content

Commit

Permalink
Remove constructor and put executor
Browse files Browse the repository at this point in the history
  • Loading branch information
markaya committed Nov 28, 2022
1 parent 33f46e8 commit 6be7bef
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 31 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
target/
/.java-version
2 changes: 1 addition & 1 deletion modules/example/src/main/scala/example/ExampleApp.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package example

import sttp.client3.httpclient.zio.HttpClientZioBackend
import zio._
import zio.elasticsearch.{DocumentId, ElasticExecutor, ElasticRequest, IndexName, Routing}
import zio.elasticsearch._

object ExampleApp extends ZIOAppDefault {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package zio.elasticsearch
import sttp.client3._
import sttp.client3.ziojson._
import sttp.model.Uri
import zio.elasticsearch.ElasticRequest.{Constructor, GetById, Map, Put}
import zio.{Task, ZIO}
import zio.elasticsearch.ElasticRequest.{GetById, Map, Put}

private[elasticsearch] final class HttpElasticExecutor private (config: ElasticConfig, client: SttpBackend[Task, Any])
extends ElasticExecutor {
Expand All @@ -15,14 +15,9 @@ private[elasticsearch] final class HttpElasticExecutor private (config: ElasticC

override def execute[A](request: ElasticRequest[A]): Task[A] =
request match {
case c: Constructor[_] => executeConstructor(c)
case map @ Map(_, _) => execute(map.request).map(map.mapper)
}

private def executeConstructor[A](constructor: Constructor[A]): Task[A] =
constructor match {
case getById: GetById => executeGetById(getById)
case put: Put => executePut(put)
case r: GetById => executeGetById(r)
case r: Put => executePut(r)
case map @ Map(_, _) => execute(map.request).map(map.mapper)
}

/*
Expand All @@ -38,27 +33,7 @@ private[elasticsearch] final class HttpElasticExecutor private (config: ElasticC
* PUT /baseURL/<index>/_create/<id>
* POST /baseURL/<index>/_create/<id>
* */

private def executePut(put: Put): Task[Unit] = {
// val request = basicRequest
// .post(
// uri"$baseUrl/${put.index}/_doc/"
// )
// .body(putBody)
// .contentType("application/json")
//
// request.send(client).flatMap { a =>
// println(a.statusText)
// a.body match {
// case Left(value) =>
// println(value)
// ZIO.succeed(())
//
// case Right(value) =>
// println(value)
// ZIO.succeed(())
// }
// }
println(put)
ZIO.unit
}
Expand Down

0 comments on commit 6be7bef

Please sign in to comment.