Behavior overhaul #11

merged 28 commits into from Jan 31, 2017


None yet
1 participant

notxcain commented Dec 20, 2016

This PR resolves #5.

  • Entity behavior is now specified as a natural transformation EntityOp ~> Handler[State, Event, ?], where Handler[State, Event, Reply] is just a wrapper around State => (Seq[Event], Reply), you can think of it as Kleisli[(Seq[Event], ?), State, Reply] i.e. a side-effecting function with a side effect being a sequence of events representing state change caused by operation.
  • Folding of events to an entity state is now made using Folder[F[_], A, B] typeclass which represents ability to fold A to B with effect F[_]. Until further abstraction the folding effect required by AkkaRuntime is Folded[A], which makes it possible to represent impossible folding states, using Folded.impossible, which is converted to recovery exception by underlying actor.
  • Event tagging is now separated from entity name used as persistence id prefix. Event tagging respects underlying Cassandra journal in a way that it allows to add no more that 3 tags per event, with only one tag possibly being dynamic, i.e. depend on the contents of event being tagged.
  • Correlation is now a type alias for EntityOp ~> λ[x => CorrelationId]
  • Event and Snapshot serialization and deserialization are now performed using type classes PersistentEncoder[A] and PersistentDecoder[A] correspondingly. There is fromCodec constructor to simplify migration. You may need to migrate you events replacing ser_id column with a 100, or use your own subclass of PersistentReprSerializer instead of your old serializer, which you can delete them afterwards. NOTE: Command message serializers are still needed to be provided. I'm working on lifting them to type level, however there is a possible penalty of unnecessary serialization of commands to local actors.

@notxcain notxcain self-assigned this Jan 31, 2017

@notxcain notxcain added this to the 0.13.0 milestone Jan 31, 2017

@notxcain notxcain merged commit 8f23432 into master Jan 31, 2017

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
continuous-integration/travis-ci/push The Travis CI build passed

@notxcain notxcain deleted the behavior-overhaul branch Jan 31, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment