Comments (4)
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.
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.
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.
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)
- Support for Scala 2.13 HOT 1
- Removal of `handleCommandAsync`, `tryToHandleCommand` and `manyEvents` methods
- timeout for applyCommand HOT 4
- Eventhandling idempotency possibly flawed HOT 5
- Simplifying Command and Events
- AkkaBackend: Sender doesn't get any notification in case of empty list of Events
- Make the InMemoryBackend more flexible HOT 3
- Improve error message when Aggregate is not configured HOT 1
- Support for Scala 2.12
- Upgrade EventsSourceProvider to use akka.persistence.query.EventEnvelope2 in Akka 2.4 HOT 3
- Actor is not unique exception when configuring two backends in the same actor system. HOT 2
- Replace type projections by path dependent types
- Command and Event Handlers as PartialFunction HOT 1
- RxScala dependency for 2.11 HOT 7
- PersistedOffsetAkka mechanism inefficient HOT 6
- The EventsMonitorActor is hardcoded to timeout after 10 seconds
- AggregateActor "pipeTo self" bypasses termination logic of AggregateManager HOT 3
- Future of fun-cqrs HOT 5
- Multiple aggregates per actor system? HOT 4
- Would you be willing to accept a pull request for the Projection trait to have a additional method handler when event is successfully handled? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fun-cqrs.