Giter VIP home page Giter VIP logo

Comments (4)

octonato avatar octonato commented on May 29, 2024 1

Good point. Scala 2.12 is almost there so we could put support for Xor on hold and have it only for the new biased Either.

And of course, support for Validated

from fun-cqrs.

patricknoir avatar patricknoir commented on May 29, 2024

Hi Renato, given that Cats is deprecating Xor in favour of the new Either in scala 2.12 (right biased) do you see still see a value to provide support for Xor?

from fun-cqrs.

octonato avatar octonato commented on May 29, 2024

I have done some progress on this (only analysis and some basic design) and some ideas and issues cames to the surface.

The main problem I'm facing right now is that whatever effect we choose on the behavior side, it always get transformed to the effect of the backend we use.

For instance, we have three effects that we can use when defining command handlers: Future, Try and Identity.

A command handler using Identity will return Identity when using the InMemoryBackend and it will be transformed to Future when using the AkkaBackend.

That means the the effects on the behavior definition are not necessarily preserved once executed by the backend.

I found a good solution to extend Actions with new effects: Validated, Either, scalaz.Validation, etc. This will give flexibility when defining command handlers, but whatever effect we choose, it will be discarded once executed. A Validated will have to be converted to a Future.

We will end-up with something like:

Validated[NonEmptyList[String],Events]
class InvalidException(errors: NonEmptyList[String])

// assuming AkkaBackend
val result = aggregateRef ? cmd
// in case of failures, result completes with 
// Failure(InvalidException)

Which is awkward.

The only way of having a Validated being returned by a command is by having a CatsBackend.

from fun-cqrs.

octonato avatar octonato commented on May 29, 2024

It's now possible to build an extensions (ie: new InvokerDirectives) for Cats (see #63).

However, I'm considering making Cats a full citizen in Fun.CQRS. I'm using it in an internal project right now, especially Validated and I'm quite happy with the results.

It's especially handy for fine-grained events. Whenever we have a Command that may emit many Events. In that case, if we reject the Command we can enumerate all the reasons why is was rejected.

from fun-cqrs.

Related Issues (20)

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.