Add a `memoizedAcquire` method to `Resource`
Ref #3513
I'm not sure how to unit test this exactly, I'm open to guidance or commits for that
To test this I would write to Refs in your acquire and use, and assert on the state of those refs to check that it's behaving as you expect. I wouldnt worry about concurrent testing since memoize is pulling most of the weight
I don't think we need to add any new tests specifically because of this PR, unless there are existing gaps in the existing memoize tests.
To be clear, what I'm proposing is that we refactor so it looks like this:
def memoizedAcquire(ra: Resource[F, A]): Resource[F, F[A]] =
/* move existing memoize implementation here */
def memoize(ra: Resource[F, A]): Resource[F, Resource[F, A]] =
memoizedAcquire.map(Resource.eval(_))
Then all the existing memoize tests can just be in terms of memoizedAcquire.
Yeah fair enough, with that refactor I would agree that we don't need any new tests
I'm a huge fan of not having to add new tests. I will get to that refactor when/as I have time but if anyone wants to beat me to it, the branch is open for maintainer commits ;)
I don't have the time to update this branch with the changes but I encourage anyone motivated to take over
Hi @Daenyth, I would be interested in taking this over if that's ok. I'd love to see this feature land in the 3.6 release :-)
@satabin Go for it! I think you'll need to pull this branch locally and open a new pull request so you can push to it. Please be sure to refrain from rebasing the commits; we can carry the conversation more easily from this PR to that one if the shas are not rewritten.
I opened #4105 to continue the work on this PR.