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

ZIO Module example app with error handling #90

Open
AugustNagro opened this issue Jan 15, 2025 · 7 comments · May be fixed by #97
Open

ZIO Module example app with error handling #90

AugustNagro opened this issue Jan 15, 2025 · 7 comments · May be fixed by #97

Comments

@AugustNagro
Copy link
Owner

No description provided.

@lvitaly
Copy link
Contributor

lvitaly commented Jan 19, 2025

@guizmaii
Copy link
Contributor

@lvitaly Nice! Thanks

Some minor comments:

object BookRepository:
  val layer: URLayer[Transactor, BookRepository] =
    ZLayer {
        ZIO.serviceWith[Transactor](BookRepositoryLive(_))
    }

can be simplified with:

object BookRepository:
  val layer: URLayer[Transactor, BookRepository] = ZLayer.derived[BookRepositoryLive]
  1. BookRepositoryLive class could be final (better for JIT)

🙂

@lvitaly
Copy link
Contributor

lvitaly commented Jan 19, 2025

@guizmaii, thanks! I knew there should be a simpler way to create such layers.

By the way, guys, if you have something particular in mind as an example, I would love to help you with it.

@guizmaii
Copy link
Contributor

@lvitaly I think the missing example is a transaction in which the code throws an exception to revert it.
I have partially shown that in our talk

@lvitaly
Copy link
Contributor

lvitaly commented Jan 22, 2025

Hey, probably you know, but... The readme file and the presentation declare a ZIO module as magnum-zio, but in reality, it's actually magnumzio without the hyphen.

Readme:

"com.augustnagro" %% "magnum-zio" % "x.x.x"

mvnrepository:

"com.augustnagro" %% "magnumzio" % "2.0.0-M1"

@lvitaly lvitaly linked a pull request Jan 23, 2025 that will close this issue
@AugustNagro
Copy link
Owner Author

Great work, thanks for taking this on @lvitaly . I'm happy to merge as-is, and we can create issues & iteratively enhance from there.

@AugustNagro
Copy link
Owner Author

AugustNagro commented Jan 23, 2025

One thought I have (that we can address later) is that the example app be as realistic as possible. Since TestContainers should only be used for tests, it makes sense to strip that out and use an actual dockerfile with PG.

Going even further, I would like to see this become a g8 template that includes ZIO HTTP as well. I created https://github.com/AugustNagro/magnum-zio-http.g8 (empty g8 template)

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 a pull request may close this issue.

3 participants