DDD/CQRS/ES/NoSQL and functional programming

Tags: #<Tag:0x00007f1162f02ec0> #<Tag:0x00007f1162f01110>


f(by) - Conference on Functional Programming 2015-11-28 (Belarus 17:30-18:30)

Event Sourcing is actually just functional code

by Greg Young

This talk will go through the concept of event sourcing and show that at its core its really just functional code. You can implement an event sourced system in Object Oriented code but its really hiding what is happening. Have you seen the logo for event store or the cute little dragon? By the end of this talk you will also understand what they mean.


Just stumbled upon this list of DDD resources: https://gist.github.com/somebox/21c7c9ca3a62de9ac65a366fbb8c3250


Hey all, looks like this could benefit from being a wiki - done :slight_smile: Feel free to keep it updated with important info/links etc

cc/ @kraades


Where is the wiki?


The first post of the thread - just click on the edit button to add to it :slight_smile:


Please, take a look at our new proposal for Commanded CQRS framework:


Does anyone know of an event-store that runs in-process? Something like CouchDB or Commanded, but 100% Elixir running in the same process as my application code? I guess I’m looking for the SqLite of event-stores, written in Elixir…


There’s a pending pull request to Commanded that extracts out the storage adapter and provides an additional implementation for Greg Young’s Event Store. With the storage interface now defined as a behaviour you could write an in-memory provider. That would give you a full CQRS/ES library, all in memory and written in pure Elixir.

I do want to implement an in-memory storage provider to use for unit tests. Sorry, I can’t commit to getting it done right now.


If the information you will store is less than 2gigs then the built-in Mnesia will work. But to say which is best is determined based on what you will be storing, how it will be stored, and how it will be looked up.


@slashdotdash and @OvermindDL1 - thanks for your responses.

Another more general question - I’m trying to figure out a strategy for dealing with Code change in my Event Sourced app. Can you point me at a a good reference or talk that explains different strategies for managing code changes, especially when you need to change the format of the messages stored in the Event Store?


I version my messages and just run them through converters.

event = %EventMsg{vsn: 3, blah: :blorp} # Except you can make the 'current' `vsn` the default value too


The Dark Side of Event Sourcing: Managing Data Conversion is a good research paper covering the main strategies for versioning events.

  • Multiple versions
  • Upcasting
  • Lazy transformation
  • In place transformation
  • Copy and transformation

I wrote an Elixir library (eventstore-migrator) that implements the copy and transform strategy for my own event store. It copies and mutates events into a new PostgreSQL database. You can transform, remove, aggregate, and alter the serialization format of the events.

Here’s an example of removing an unwanted event.

EventStore.Migrator.migrate(fn stream ->
    fn (event_data) -> event_data.event_type == "UnwantedEvent" end

There are other examples in the README, including: upgrade an event; aggregate multiple events into one event; alter event serialization format.


Thank you @slashdotdash - this paper is wonderful. @OvermindDL1 thanks also for your versioning / reformatting tip.



Greg Young is writing a self-publish eBook on the subject too. It’s free to read online or $12.99 USD to buy.


Event Sourcing in Elixir by Derek Kraan.


I’ve created an “awesome list” of Elixir and CQRS/ES resources: Awesome Elixir and CQRS.

The list is designed for only CQRS/ES resources that explicitly target Elixir/Erlang, as there’s an existing awesome collection of general domain-driven design content.

Contributions via pull request most welcome.


Reactive Microsystems - The Evolution Of Microservices At Scale” by Jonas Bonér. Published by O’Reilly, and it’s free to download and read.

It’s a succinct introduction to reactive microservices and event driven architecture (CQRS/ES). Well worth a read.