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

Resource computation block #2571

Merged
merged 13 commits into from Nov 11, 2021
Merged

Resource computation block #2571

merged 13 commits into from Nov 11, 2021

Conversation

nomisRev
Copy link
Member

@nomisRev nomisRev commented Nov 4, 2021

This PR adds a Computation block DSL for Resource.

It also rewrites the internals of Resource slightly, it now uses Kotlin Coroutines to unroll Resource through bracketing suspend.
This way we can guarantee that for every Resource that started acquisition we will call the finalizer in order (FIFO).

@nomisRev nomisRev requested review from raulraja, 1Jajen1, i-walker and a team November 4, 2021 20:03
@nomisRev nomisRev added the arrow-fx Tickets belonging to Arrow Fx label Nov 4, 2021
}.use { it }
} shouldBe "error".left()
// Should be ExitCase.Cancelled but still Failure due to ShortCircuit
// Cont<R, A> will fix this issue by properly shifting and cancelling
Copy link
Member

@i-walker i-walker Nov 4, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙌🏾 one awesome feature

Copy link
Member

@i-walker i-walker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks awesome 🙌🏾

@@ -496,36 +530,6 @@ public sealed class Resource<out A> {
public fun <A> defer(f: suspend () -> Resource<A>): Resource<A> =
Resource.Defer(f)
}

private suspend fun continueLoop(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙌🏾

@nomisRev nomisRev requested a review from a team November 6, 2021 09:59
Copy link
Member

@raulraja raulraja left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @nomisRev !

@nomisRev nomisRev merged commit 9928d16 into main Nov 11, 2021
@nomisRev nomisRev deleted the sv-resource-computation-block branch November 11, 2021 09:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arrow-fx Tickets belonging to Arrow Fx
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants