Code Monkey home page Code Monkey logo

event-store-stream's People

Stargazers

 avatar

event-store-stream's Issues

Denormalizer, Effector don't catch errors thrown by the effects they run

Right now if a query/effect throws an error it will bring down the Denormalizer or Effector. This might not be the right behavior.

In the case of a Denormalizer, not stopping upon encountering an error could result in an inconsistent read model because we will have missed an event. On the other hand, perhaps the user wants to signal that the event in some way should not be incorporated by throwing an error (rather than the error occurring at a lower level). A possible solution is to introduce a specific error type for this sort of thing, and catch only that type of error, and rethrow anything else. It could be neatly wrapped up in a couple of functions, one for throwing and one for catching. A possible use case for this could be skipping the rest of a computation when a Maybe is Maybe.Nothing.

With Effector, there is also the possibility of weird stuff happening due to inconsistency as well. An email DSL could, for example, store a user's name whenever it changes and read that from its storage whenever sending an email. If the update fails, then future emails might use the wrong name. The effects here probably aren't as devastating as a bad read model, but they can still cause a lot of problems.

I think the best thing to do is probably:

  • Make the special error type and handler function
  • Add a retry function to retry a failed effect that can be used by the "mappers"
  • Log any other errors that bubble up to the Denormalizer or Effector.
    • This will allow the rest of the system to continue operating when something bad happens, and hopefully allow the inconsistencies caused by the error to be detected early enough that fixing them is inexpensive. The current behavior is way too disruptive, even though it would stop inconsistencies from happening.

The first two should probably go into monadic-js and work abstractly with any Monad that supports failing and catching (MonadFail). In fact, the skipping piece should probably just be m.fail(skip) and the catching piece should be m.catch(continue) where skip is a value of the special error type and continue is a handler that returns m.of() when the error is the special one and m.fail(err) when the error is anything else. Retry should just take an appropriate function (MonadFail m => a -> m b) and a number of attempts to make, and return a new function of the same type that does the same thing with retry-n-times-then-fail semantics.

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.