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

Remove Par typeclass #166

Merged
merged 12 commits into from
Nov 12, 2018
Merged

Remove Par typeclass #166

merged 12 commits into from
Nov 12, 2018

Conversation

purrgrammer
Copy link
Contributor

@purrgrammer purrgrammer commented Oct 29, 2018

After discussing with @peterneyens how we could get rid of the Par typeclass he suggested using Concurrent#start and Fibers to achieve parallelism whenever we used parTraverse. This is my first approach to implementing it.

  • Removes cats-par dependency
  • Removes Par implicit requirement
  • Implements parallelism in terms of Concurrrent#start and Fiber's
  • Support cancellation of parallel fetches

@codecov
Copy link

codecov bot commented Oct 29, 2018

Codecov Report

Merging #166 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff           @@
##           master    #166   +/-   ##
======================================
  Coverage    95.2%   95.2%           
======================================
  Files           5       6    +1     
  Lines         167     167           
  Branches        4       7    +3     
======================================
  Hits          159     159           
  Misses          8       8
Impacted Files Coverage Δ
shared/src/main/scala/syntax.scala 100% <ø> (ø) ⬆️
shared/src/main/scala/cache.scala 100% <ø> (ø) ⬆️
shared/src/main/scala/datasource.scala 100% <100%> (ø) ⬆️
shared/src/main/scala/fetch.scala 95.39% <100%> (-0.04%) ⬇️
shared/src/main/scala/execution.scala 100% <100%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fcaac28...f803eab. Read the comment docs.

@purrgrammer
Copy link
Contributor Author

I'm not sure if we can support running parallel computations and making them cancelable, since the Concurrent#cancelable looks like the following:

import cats.effect.{Async, Fiber, IO, CancelToken}

trait Concurrent[F[_]] extends Async[F] {
  // ...
  def cancelable[A](k: (Either[Throwable, A] => Unit) => CancelToken[F]): F[A]
}

For now I've made the fibers we spawn uncancelable, so in case the fetch computation is cancelled, it will terminate as soon as all concurrent fibers have finished executing.

@purrgrammer
Copy link
Contributor Author

I have some ideas for supporting cancellation of parallel computations, I'll update the PR when I manage to implement it.

@raulraja
Copy link
Contributor

raulraja commented Nov 3, 2018

Looks great so far, let me know when ready for final review. 🍻

@purrgrammer
Copy link
Contributor Author

@raulraja not sure why the coverage doesn't cover the newly introduced execution.scala file but this PR is ready for review!

Copy link
Contributor

@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.

This looks great, if @peterneyens has no additional comments I think this is good to go. kudos and great work!


def countFetches(r: Request): Int =
r.request match {
case FetchOne(_, _) => 1
Copy link
Contributor

Choose a reason for hiding this comment

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

Formatting seems off in a few match cases here. Are we enforcing auto formatting with Scalafmt or similar?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not right now, I can open a separate PR for adding scalafmt and not polluting this one

@purrgrammer
Copy link
Contributor Author

Cleaned this up following @peterneyens suggestions, let me know if ✔️

@purrgrammer purrgrammer merged commit d9af77c into master Nov 12, 2018
@purrgrammer purrgrammer deleted the remove-par branch November 12, 2018 14:55
@jtjeferreira
Copy link

any chance to make a release (RC or milestone) with this PR included? Would like to try this for a small project...

bijancn pushed a commit to bijancn/fetch that referenced this pull request Sep 19, 2019
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 this pull request may close these issues.

None yet

4 participants