DDD/CQRS/ES/NoSQL and functional programming

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

3 Likes

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:

1 Like

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

3 Likes

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ā€¦

2 Likes

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.

1 Like

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.

1 Like

@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?

1 Like

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
2 Likes

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 ->
  Stream.reject(
    stream,
    fn (event_data) -> event_data.event_type == "UnwantedEvent" end
  )
end)

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

3 Likes

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

1 Like


3 Likes

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

4 Likes

Event Sourcing in Elixir by Derek Kraan.

1 Like

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.

9 Likes

ā€œ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.

4 Likes

DDD + distributed systems

1 Like