-
Couldn't load subscription status.
- Fork 1.4k
Redesign ZManaged around an embedded finalizer map #3510
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
Conversation
|
@ioleo I'm fairly confident that ZLayer is constructed correctly now, but the mocking specs are still not passing. Any chance you could look into this? |
| } | ||
| } | ||
| def flatMap[R1 <: R, E1 >: E, B](f: A => ZManaged[R1, E1, B]): ZManaged[R1, E1, B] = | ||
| ZManaged(self.zio.flatMap { case (_, a) => f(a).zio }) |
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.
Isn't the finaliser of the first effect important to keep here?
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.
That's a good question. The finalizers returned from the underlying ZIO are only used for early release.
I'm wondering if the correct thing to do is only allow the resulting ZIO to be released early, or should an early release of the resulting ZIO should also release the flatMapped ZIO.
Will think about this. Thank you for pointing this out!
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.
Ok, it's definitely right to compose the early release finalizers as well. Thanks @regiskuckaertz.
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.
Ha, I even did that without thinking for ZManaged.foreach.
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.
nice 👌
c7c3d5e to
4961eea
Compare
| )(zero: B)(f: (B, A) => B): ZIO[R, E, B] = | ||
| Ref.make(zero) >>= { acc => | ||
| foreachParN_(n)(in) { | ||
| Predef.identity(_) >>= { a => acc.update(f(_, a)) } |
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.
Do you need the Predef.identity? 😮
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.
It’s shadowed by ZIO.identity 🤷🏼♂️
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.
Oh sorry I misread. This is silly. Will fix.
I admit to just copying the mergeAllPar implementation 😂
| release = finalizers.runAll | ||
| ) | ||
| } | ||
| def zipWithPar[R1 <: R, E1 >: E, A1, A2](that: ZManaged[R1, E1, A1])(f: (A, A1) => A2): ZManaged[R1, E1, A2] = |
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.
nice simplification 😲
|
This is amazing |
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.
Looks gorgeous and ready to me 🕺🏻
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.
Looks incredible!
6547336 to
6f5d0b9
Compare
No description provided.