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

Conversation

mvelimir
Copy link
Member

@mvelimir mvelimir commented Feb 7, 2023

No description provided.

@@ -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)))
Copy link
Collaborator

@mijicd mijicd Feb 10, 2023

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.

@mvelimir mvelimir marked this pull request as ready for review February 22, 2023 14:35
drmarjanovic
drmarjanovic previously approved these changes Feb 22, 2023

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)
Copy link
Collaborator

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))
Copy link
Collaborator

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)
Copy link
Collaborator

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.

drmarjanovic
drmarjanovic previously approved these changes Feb 22, 2023
dbulaja98
dbulaja98 previously approved these changes Feb 23, 2023
@mvelimir mvelimir dismissed stale reviews from dbulaja98 and drmarjanovic via c107f17 February 23, 2023 12:45
@drmarjanovic drmarjanovic changed the title Use module pattern 2.0 (remove execute method on requests) Use module pattern (remove execute method on requests) Feb 23, 2023
@drmarjanovic drmarjanovic merged commit c9110a1 into main Feb 23, 2023
@drmarjanovic drmarjanovic deleted the module-pattern-2.0-1 branch February 23, 2023 19:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants