Code Monkey home page Code Monkey logo

zio-event-sourcing's Introduction

ZIO Event Sourcing

ZIO EventSourcing is library trying to adopt one of CQRS implementations to ZIO way.

Description

Most of application could be seen as sequence of user initiated events that change state of the entire system. Keeping this in mind we could say that all entire system state could be restored just by playback of whole history of user initiated events, or some times just a part of them to business-logic processors (if they are "state less"). But also we need to keep in mind that modern time our services need to be fault-tolerant, scalable and able to adopt to always changing requirements of Clients and Business. And also we have requirement to provide our marketing team tools to allow to sell our product and keep KPI progress on it.

Combining previous requirements we have that modern system:

  • Should not lose any of "user initiated data"
  • Should be able to recover from most possible ways corrupting "customer data"
  • Should have natural ability to scale on either "user input/output" or marketing analytics data

Event sourcing addresses this issues by separating "read side" and "write side" It has "event journal" which stores incoming events ordered in time for each entity ("Aggregate"). When entity state needs to be accessed "Aggregate" loads stored events and computes totals state

Concepts

  • Everything happening to system is "event"
  • Every "interesting" event is recorded to EventJournal
  • Every successful persisted event changes calculated state of Aggregate
  • Every state could be reassembled by playback of all eventgits to specific Aggregate
  • Any of EventJournals could be assembled to multiple Aggregates

Benefits

  • Separating read and write sides eliminates all possibilities of "race conditions" in concurrent environments (all changes are being processed on stable order)
  • Ability to recover from "cold data"
  • Ability to add new type of business or analytics aggregates at any time
  • Possibility to take most advantages from Cassandra\Scylla\Aerospike storages

Drawbacks

  • To get current state of aggregate you need to read all its data (addressed at "read side" by snapshot storage or other caching techniques)
  • In real life you will need to have some "distributed tracing" support to debug issues
  • Having some problems doing distributed transactions (addressed by zio-saga)

Usage

resolvers += Resolver.bintrayRepo("holinov", "maven") 
libraryDependencies ++= Seq(
 "FruTTecH" %% "zio-event-sourcing" % "0.1.10",
 "FruTTecH" %% "zio-event-sourcing-serializer-protobuf" % "0.1.10",
 "FruTTecH" %% "zio-event-sourcing-file-store" % "0.1.10",
 "FruTTecH" %% "zio-event-sourcing-cassandra-store" % "0.1.10"
)

Roadmap

  • Publish to Bintray
  • Publish to Maven Central
  • Storage examples for Cassandra/Scylla
  • Storage examples for zio-rocksdb
  • Optional state snapshot storage
  • zio-saga example
  • zio-kafka example

zio-event-sourcing's People

Contributors

holinov avatar tampler avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

zio-event-sourcing's Issues

Project finished or discontinued?

Hi there, event sourcing is a good thing and zio is a good thing, is this finished or discontinued?
Is Akka the only event sourcing I can do from Scala without this?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.