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

Use module pattern (remove execute method on requests) #83

Merged
merged 9 commits into from
Feb 23, 2023
Prev Previous commit
Next Next commit
Remove Throwable from layer creation
  • Loading branch information
mvelimir committed Feb 23, 2023
commit 364303a44c4c96446446bbe7b91878b0de428fae
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@ package zio.elasticsearch

import sttp.client3.SttpBackend
import zio.stm.TMap
import zio.{Task, ULayer, ZLayer}
import zio.{Task, ULayer, URLayer, ZLayer}

private[elasticsearch] trait ElasticExecutor {
def execute[A](request: ElasticRequest[A, _]): Task[A]
}

object ElasticExecutor {
lazy val live: ZLayer[ElasticConfig with SttpBackend[Task, Any], Throwable, ElasticExecutor] =
lazy val live: URLayer[ElasticConfig with SttpBackend[Task, Any], ElasticExecutor] =
ZLayer.fromFunction(HttpElasticExecutor.apply _)

lazy val local: ZLayer[SttpBackend[Task, Any], Throwable, ElasticExecutor] =
lazy val local: URLayer[SttpBackend[Task, Any], ElasticExecutor] =
ZLayer.succeed(ElasticConfig.Default) >>> live

lazy val test: ULayer[TestExecutor] =
Expand Down