Giter Club home page Giter Club logo

deferrable_gratification's People

Contributors

ept avatar samstokes avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

deferrable_gratification's Issues

Join that does not swallow failures

I spent a while trying to track down a bug that was masked by DG::join_successes. What happened was something like this:

def operation(param)
  something_async(param).transform do |value|
    call_some_method_that_does_not_exist! # raises NameError
  end
end

def one_two_three
  DG::join_successes operation('one'), operation('two'), operation('three')
end

That NameError caused each operation to fail, but because join_successes discarded the failures, one_two_three succeeded. I had error logging on an errback, but it never got logged, which left me scratching my head for a while.

In a context where the constituent deferrables are expected to succeed, it would be nicer for the join combinator to immediately escalate any failure. Something like this:

# If any of the joined deferrables fails, fails immediately with that failure's error.
# Otherwise waits for all deferrables to succeed, and succeeds with an array of success results.
class JoinCarefully < DeferrableGratification::Combinators::Join
  private
  def done?
    failures.length > 0 || all_completed?
  end

  def finish
    if failures.empty?
      succeed(successes)
    else
      fail(failures.first)
    end
  end
end

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.