-
Notifications
You must be signed in to change notification settings - Fork 18
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
Conversation
@@ -45,14 +45,14 @@ object Main extends ZIOAppDefault { | |||
val deleteIndex: RIO[ElasticExecutor, Unit] = | |||
for { | |||
_ <- ZIO.logInfo(s"Deleting index '$Index'...") | |||
_ <- ElasticRequest.deleteIndex(Index).execute | |||
_ <- ZIO.serviceWithZIO[ElasticExecutor](_.execute(ElasticRequest.deleteIndex(Index))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one is not bad, though it might need to adjust types to make it fully type-safe and maximize ergonomics.
9098283
to
e21e5b6
Compare
modules/library/src/it/scala/zio/elasticsearch/IntegrationSpec.scala
Outdated
Show resolved
Hide resolved
modules/library/src/main/scala/zio/elasticsearch/Elasticsearch.scala
Outdated
Show resolved
Hide resolved
|
||
def findById(organization: String, id: String): Task[Option[GitHubRepo]] = | ||
for { | ||
routing <- routingOf(organization) | ||
req = ElasticRequest.getById[GitHubRepo](Index, DocumentId(id)).routing(routing) | ||
res <- executor.execute(req) | ||
res <- elasticsearch.execute(req) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we inline the requests?
@@ -30,51 +30,53 @@ object HttpExecutorSpec extends IntegrationSpec { | |||
test("successfully create document") { | |||
checkOnce(genCustomer) { customer => | |||
for { | |||
docId <- ElasticRequest.create[CustomerDocument](index, customer).execute | |||
res <- ElasticRequest.getById[CustomerDocument](index, docId).execute | |||
docId <- Elasticsearch.execute(ElasticRequest.create[CustomerDocument](index, customer)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is the spec for the Executor
itself, I would use it directly here.
@@ -66,7 +66,9 @@ object HttpElasticExecutorSpec extends WireMockSpec { | |||
) | |||
) | |||
|
|||
assertZIO(addStubMapping *> ElasticRequest.bulk(ElasticRequest.create(index, repo)).refreshTrue.execute)( | |||
assertZIO( | |||
addStubMapping *> Elasticsearch.execute(ElasticRequest.bulk(ElasticRequest.create(index, repo)).refreshTrue) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would rely directly on the layer that is being tested by the spec.
c107f17
db2abbb
to
c107f17
Compare
No description provided.