-
Notifications
You must be signed in to change notification settings - Fork 23
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
cats-effect 3.1.x for Rerunnable -> Sync + Clock + MonadCancel #267
Conversation
4d93109
to
14bfb87
Compare
I rebased the branch onto master and did some further build tweaks, so everything is in a decent state to move from M2 to M5. |
I asked in the As for the target scope, I want to try and support three things:
|
Codecov Report
@@ Coverage Diff @@
## master #267 +/- ##
==========================================
- Coverage 91.35% 88.00% -3.36%
==========================================
Files 9 6 -3
Lines 162 125 -37
Branches 3 1 -2
==========================================
- Hits 148 110 -38
- Misses 14 15 +1
Continue to review full report at Codecov.
|
Since 3.0.0-RC1 dropped the strict cancelation requirements for Without the cancelation requirement we might even be able to support more of the typeclass hierarchy than in 2.x. I will also take a look into the drop in coverage, of course. |
I spoke a bit too soon. Implementing |
@travisbrown Hi, so since cats-effect 3 is stable, we probably should figure out how to release catbird for that. I still have to put in some work in this PR (in particular why codecov is so unhappy) but for the most part the code should work. The big question for me is if we need to have a cross-released version for say Finagle 21.X.0 and both cats-effect 2 and 3 or if we just release catbird with Finagle 21.X.0 with cats-effect 2 and Finagle 21.(X+1).0 with cats-effect 3. Maybe we can get away with only cross-publishing if someone explicitly asks for it. 🤔 What are your thoughts on that? |
@felixbr I'm happy to take on the medium-term maintenance burden of cross-publishing releases (especially if it's for some fixed period of time), but unfortunately I don't think I'll have time any time soon to help in detail with the update or build setup. |
Ok, so instead of merging this into master (once it's done, ofc) we'd put it on a branch and publish the versions separately. For example: After we've done this for 21.5.0 and maybe 21.6.0 we'd continue with cats-effect 3.x only. I'm sadly also quite busy but I'll try to get everything in a clean state for this in the next weeks. *21.5.0 is just an example, there's no rush imo. |
I think if possible I'd prefer to have separate source trees (possibly with a shared part) in a single branch, similar to what we do in circe-jackson to cross-publish for different Jackson versions. I don't have a strong opinion, though, and am happy to go either way. |
So two separate sub-projects in sbt for |
Great, thanks! The circe-jackson model may not be optimal but it more or less works, so you might consider it as a starting point. |
@felixbr do you need any help to get this merged? |
@catostrophe This is far from ready to be merged but the limiting factor is mostly a lack of free time to work on it. I hope you aren't blocked by this? |
@felixbr actually I am, transitively. |
@catostrophe Well, that's unfortunate. If you want to help, there are tasks which you could already do to make this PR easier to fix:
If you want to work on one of those things, you can open PRs for the |
Thanks, I will take a look in the next days |
abbf620
to
cbaff8d
Compare
Codecov Report
@@ Coverage Diff @@
## master #267 +/- ##
==========================================
- Coverage 91.82% 90.24% -1.58%
==========================================
Files 9 6 -3
Lines 159 123 -36
Branches 3 1 -2
==========================================
- Hits 146 111 -35
+ Misses 13 12 -1
Continue to review full report at Codecov.
|
GitHub Actions seem to have downtime right now: actions/runner-images#2179 (comment) |
The last codecov report is weird. The 2 files that have a significant drop in coverage are ones I haven't touched at all (as after the last force-push I'm only adding new files in Maybe codecov got confused because I rewrote the whole feature-branch. Anyway. I'm not claiming that I've incorporated the review feedback from @catostrophe but If there is anything else missing let me know. 🙂 |
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.
FYI, I have been experimenting with an idea to implement fibers and cancellation for CE3. Not yet sure whether it will pan out, but it would be good to have this as a base to build on so I'd like to help out however I can. I'm on gitter if anyone would like to chat about it.
I agree with the separate-source-tree approach, I think this should be considered a clean slate rather a rework of the CE2 version.
I also have some catbird-native testing infrastructure that could be integrated into this (though not at the expense of getting it merged, it can always be added later).
@felixbr @dangerousben Just a heads up that this repo has now moved from my individual account to the Typelevel organization. In my experience GitHub's forwarding in these situations is solid and works indefinitely (?), so it shouldn't affect anything here, but it'd probably be a good idea to update your references locally at some point. |
Thanks a lot for this PR! Is there a rough timeline for this to get merged? Also, if help is needed I'm happy to contribute where I can. |
@sebastianvoss I'll defer to @felixbr and @dangerousben on that question. I'm happy to publish a release whenever they say it's ready. |
I don't know what's holding it back personally, the codecov issue? There is a rebased version at https://github.com/dangerousben/catbird/tree/topic/cats-effect-3.0.0 if it helps. |
Codecov Report
@@ Coverage Diff @@
## master #267 +/- ##
==========================================
- Coverage 92.85% 91.12% -1.74%
==========================================
Files 14 17 +3
Lines 266 293 +27
Branches 3 1 -2
==========================================
+ Hits 247 267 +20
- Misses 19 26 +7
Continue to review full report at Codecov.
|
Great! Waiting for a release! |
Thanks a lot for the merge. Sorry for being annoying. @travisbrown, are you planning to push a release? |
Should we wait for #347? |
@sebastianvoss I'm publishing catbird-effect3 under the 21.5.0 release now, since it's a new module and the other dependencies are unchanged since 21.5.0 (apart from Scala patch versions). |
@travisbrown Cool, thanks a lot for your effort. Highly appreciated. |
Note: This is only up for discussion not really to be merged as of right now. I just use a draft PR for this, so it's easy to see code changes.
So
cats-effect
3.0.0-M2
was released and I wanted to see if the claims were true and implementing the typeclasses is easier now.For reference, the release notes have lots of useful information (the typeclass diagram in
3.0.0-M1
in particular):https://github.com/typelevel/cats-effect/releases/tag/v3.0.0-M1
https://github.com/typelevel/cats-effect/releases/tag/v3.0.0-M2
Implementing the "right" half of the typeclass diagram (namely
Clock
andSync
) was exceptionally easy. Another good thing is thatContextShift
andTimer
are gone entirely andBracket
is no longer needed according to the documentation (it still exists forResource
for some reason).The base typeclass
MonadCancel
already poses the same problems asConcurrent
incats-effect
2.x. At the momentRerunnable
is mostly a lazy wrapper aroundFuture
andPromise
and therefore delegates almost all runtime concerns to those implementations. To implement cancelation as required byMonadCancel
we'd have to introduce state somewhere to keep track of finalizers, cancelations, cancelation-masks, and possibly more.IO
keeps this state in itsFiber
abstraction and its runloop. I tried to put state intoRerunnable
itself but it got messy very quickly. We'd probably have to rethink the whole architecture and how it relates toFuture
and future pools.Another issue is that
cats-effect
expectsRerunnable
to depend oncats-effect-kernel
but we currently have a distinction betweenRerunnable
with onlycats
(in theutil
module) andcats-effect
typeclasses forRerunnable
(in theeffect
module). This makes the implementation even more complicated.You can see the
IO
implementation here: https://github.com/typelevel/cats-effect/blob/series/3.x/core/shared/src/main/scala/cats/effect/IOFiber.scalaAs far as I understand this is a fairly low-level state-machine. I don't think we can just copy this easily, as modifying the
Future
runloop is not feasible.The question for me is: Do we really need all that functionality? What are the use-cases for it?
One fairly cool thing would be to use
fs2
and derivatives directly in applications built on Finagle andFuture
. But if we have to convert betweenFuture
andRerunnable
anyway, maybe it's not too bad to convert directly toIO
instead. The latter seems to work already via functions inio.catbird.util.effect
.Another use-case I've seen is to use
Rerunnable
infinch
applications, i.e.Endpoint[Rerunnable]
. I've looked through the code there and most stuff inEndpoint[F[_]]
requiresSync[F]
orEffect[F]
.Sync
already works andEffect
no longer exists. As far as I can tellEffect
was basically used to convertRerunnable
toIO
insidefinch
, so maybe there's a solution possible sinceio.catbird.util.effect.rerunnableToIO
exists.If we still need to reimplement a runloop which supports all of
cats-effect
we might be better off starting from scratch. Fabio Labella wroteMaybe we could do something like that but instead of submitting to an
ExecutionContext
we submit to aFuturePool
.Anyway, I hope this wasn't too much rambling. If anyone has any comments, I'd love to hear them. 🙂
Cheers
~ Felix