GithubHelp home page GithubHelp logo

cats-effect-miscellaneous's People

Contributors

chepiov avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Forkers

mgyucht

cats-effect-miscellaneous's Issues

Review

WorkerPool

I like your implementation with versions, however, exec not safe wrt cancellation:

for {
  (workerVersion, worker) <- current.take
  // [X]
  currentVersion          <- version.get
  // [Y]
  b <- if (currentVersion == workerVersion)
         worker(a).guarantee(back(workerVersion, worker))
       else exec(a)
} yield b

Because of cancelable flatMaps, it's possible for cancellation to happen at [X] or [Y], in which case you leak the worker (as it's never returned to the MVar, even if I didn't do removeAll).

You can fix it using uncancelable, but you don't want to make everything uncancelable. bracket would work too (acquire and release parts of bracket are uncancelable), but looping and de-structuring would be painful.

Race

It seems (from the code) that you're building a tree of CompositeExceptions with prepend, i.e.

CompositeException(
  throwable1,
  CompositeException(
    throwable2,
    CompositeException(
      ...
    )
  )
)

It also seems that your getMessage override would not discriminate between these cases :) Ideally, you'd want to somehow ensure you work with CompositeException instead of Throwable, which you can safely combine together.

Custom extractors are a nice touch, but there's also an option to avoid matching on two cases: Either has merge method, which can only be called if left and right have (potential) same type. So, you can do something like either.leftMap(_.swap).merge to get (Fiber[...], Either[...]).


And if it all seems like nitpicking, that's because there's not really anything significant for me to complain about. Nice solutions, and congratulations ๐Ÿ‘

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.