This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2015-10-24
Channels
- # boot (183)
- # business (3)
- # clojure (65)
- # clojure-argentina (1)
- # clojure-china (1)
- # clojure-conj (2)
- # clojure-japan (2)
- # clojure-russia (5)
- # clojure-ukraine (5)
- # clojurescript (139)
- # community-development (1)
- # core-async (8)
- # core-matrix (1)
- # cursive (7)
- # datomic (2)
- # events (4)
- # hoplon (108)
- # ldnproclodo (1)
- # lein-figwheel (1)
- # liberator (1)
- # off-topic (76)
- # om (37)
- # onyx (12)
- # overtone (1)
- # testing (8)
having a bad day - am I the only one who swings between ‘yeah, I’ve got this down’ and ‘wow - what was I thinking?’
@colin.yates: Yeah, I recognize that cycle. Usually means it's time to split that task into smaller pieces. 😉 http://www.agileforall.com/splitting-user-stories/
@ericlavigne: It was more a reaction to coding/tooling in particular rather than a given use-case
Yup, when asking team to create one new thing, we split up into many individually digestible use cases. When learning something new, we try to swallow the whole watermelon at once. I think the same solution works for both problems.
And yes, I often make the same mistake, which is why I recognize your cycle. 😉
@colin.yates: I'm studying event sourcing at the moment, and it looks like you're ahead of me. Any tools you recommend for the storage/replay/query pipeline?
not really - I store the event log in an append only format in a SQL table (for non-functional reasons).
I then have a bunch of listeners which react to an event, hydrate the relevant entity from the event log and denormalise into their own structures
each one is a (Stuart Sierra) component
but I couldn’t find any decent prior art so it is all hand rolled
I would love to open source it but the great thing is that there is hardly anything to the infrastructure/glue code
were I to do it again I might utilise core async and use a document database but it is all trivially simple stuff
Best prior art I found was https://geteventstore.com/ but it is very incomplete.
That’s the one from Greg? He is definitely a guy I would listen to. But yes, I looked at that but it didn’t quite fit my workflow
Sounds like you are collecting events and interpreting them at the moment that you need to query. Sounds like an approach that would only work for very little data.
nope, I was processing the events when they happened (asynchronously) and updating denormalised read stores
@ericlavigne: That's what state snapshots are for, I think. You can snapshot the entity state at some point and then read a snapshot and query only later events when need to rehydrate.
having gone through this experience I can’t imagine not using an event-based approach for anything other than trivially simple CRUD type apps. Even then…
but, for me at least, it really did require a shift in mental aptitude when thinking about the solution space. I also pulled in DDD at the same time which was a mistake on hindsight
all the good stuff of ‘time travel’ people are experiencing with Om and Reagent - imagine that for the whole application
I haven't read DDD but the discussion on event sourcing does tend to mix with that.
So your event store is a single table with thrift-serialized events?
so you know how everybody says “I do OO” but they don’t - from what I see (and experienced myself) that applies even more to DDD.
DDD isn’t a technical discipline it is a domain modelling discipline
And you have another table tracking how far into the event stream you have processed so far?
@ericlavigne: how far each component has processed so far yes. It is great because if my view changes, simply destroy its schema and reset it back to 0
then it replays all those lovely events to create the updated view
@jaen - they are a match made in heaven. I hadn’t anticipated though how much a proper DDD approach differs from the stuff I had been doing for 20-odd years
thinking about it, there is a lot of symmetry between micro-services and event-handlers
when this insane deadline I am under passes I mean to put some effort into a set of blog posts because there is so much sympathy between FP and event sourcing - a lot of it is just good common sense.
Ok, that is a point, when I tried to get how to DDD it was so different than what people usually do I was kinda stumped hot to tackle that.
Yeah, I couldn't understand ES/CQRS when reading about it on some OO-oriented (that's double the oriented xD) websites, describing them in terms of objects and whatnot
yes - exactly
however, the complexity (for me at least) of DDD is what events and exactly how to define the aggregate roots
you can get all the benefit of event sourcing without DDD by simply storing all state changes as an explicit event.
then the entity is literally just a (apply merge (event-store/load ar-id)
And most of the challenge in schema design is trying to future-proof for new types of data you might need to store in the future without creating denormalization issues. But with event sourcing most of that is in views and you can always just create more.
exactly
there are downsides though.
you don’t realise exactly how many business decisions are made in queries until you manually capture each decision in an event!
but performance is just blindingly fast because you literally can have one view per ‘widget’ on you UI optimised just for that.
But putting an "aggregate ID" in the event implies that you already know what views you will use it for. Aggregates are your views, right?
no, aggregates is what is needed to make a decision in the domain
so Customer and all their orders might be one aggregate (with Customer being the AR), another part of the business (i.e. another bounded context) might view the Customer as a set of delivery addresses, yet another might view that Customer as a list of purchases - each ‘Customer’ instance is the same physical real world thing and has the same ID.
but each part of the app might attribute different properties to that Customer.
Strictly, aggregates in DDD are silos of integrity. You define them to ensure each business decision is safely and atomically made (where possible).
it really blows your mind.
Sounds like I need to read DDD ASAP.
http://dddcommunity.org/book/implementing-domain-driven-design-by-vaughn-vernon/ is a great book. Eric Evans’ ‘Blue Book’ is the authority but pretty old now
it also seems to have taken off much more in Microsoft land rather than Java land
I need to run; gotta snuggle up on the sofa with my four kids and watch ‘Penguins of Madagasca’. When I say ‘snuggle’ I mean ‘be sat on’
well, Greg coined the CQRS term (as an extension of CQS)
Hah; if you write something on ES/CQRS/DDD in Clojure I'll gladly read that; those are things that are better learnt from people that used it in practice
if you do want to get into DDD then I strongly suggest you go through the archives of the DDD google group - probably 9/10 messages are about “how do I do this simple thing in DDD” .
thanks @jaen - it is #1 on my TODO list once I can take a breath (current work pressure is pretty high)
see you in a few hours
That is a big book but might read anyway. Really want to switch to this approach.